feat():新增热点功能

dev2
WeiRan 2024-08-23 20:27:03 +08:00
parent 294c87aba4
commit c38e3b13a5
5 changed files with 57 additions and 2 deletions

View File

@ -45,6 +45,10 @@ public class ProductListResp {
* 0 1 * 0 1
*/ */
private Integer productState; private Integer productState;
/**
*
*/
private Integer productSales;
@Schema(description = "创建人",defaultValue = "muyu",type = "String") @Schema(description = "创建人",defaultValue = "muyu",type = "String")
private String createBy; private String createBy;
@ -67,6 +71,7 @@ public class ProductListResp {
.productPrice(product.getProductPrice()) .productPrice(product.getProductPrice())
.productContent(product.getProductContent()) .productContent(product.getProductContent())
.productState(product.getProductState()) .productState(product.getProductState())
.productSales(product.getProductSales())
.createBy(product.getCreateBy()) .createBy(product.getCreateBy())
.createTime(product.getCreateTime()) .createTime(product.getCreateTime())
.build(); .build();

View File

@ -40,7 +40,7 @@ public class FindCustomerMeaasgeController {
* @return * @return
*/ */
@PostMapping(path = "/findListByuserCard/{idCard}") @PostMapping(path = "/findListByuserCard/{idCard}")
@Operation(summary = "查询客户信息",description = "根据身份证号查询客户信息") @Operation(summary = "身份证号查询客户信息",description = "根据身份证号查询客户信息")
public Result<Customer> findListByuserCard(@Validated @PathVariable String idCard){ public Result<Customer> findListByuserCard(@Validated @PathVariable String idCard){
return Result.success(findCustomerMeaasgeService.findListByuserCard(idCard)); return Result.success(findCustomerMeaasgeService.findListByuserCard(idCard));
} }
@ -51,7 +51,7 @@ public class FindCustomerMeaasgeController {
* @return * @return
*/ */
@PostMapping(path = "/findListByuserPhone/{tel}") @PostMapping(path = "/findListByuserPhone/{tel}")
@Operation(summary = "查询客户信息",description = "根据手机号查询客户信息") @Operation(summary = "手机号查询客户信息",description = "根据手机号查询客户信息")
public Result<Customer> findListByuserPhone(@Validated @PathVariable String tel){ public Result<Customer> findListByuserPhone(@Validated @PathVariable String tel){
return Result.success(findCustomerMeaasgeService.findListByuserPhone(tel)); return Result.success(findCustomerMeaasgeService.findListByuserPhone(tel));
} }

View File

@ -88,6 +88,17 @@ public class ProductApiController {
} }
/**
*
* @return
*/
@RequestMapping(path ="/hotspotlist",method = RequestMethod.GET)
@Operation(summary = "热点产品查询",description = "查询销量排名前五的产品")
public Result<List<ProductListResp>> findhotspotproduct(){
return Result.success(productApiService.selecthostportList());
}

View File

@ -22,4 +22,12 @@ public interface ProductApiService extends IService<Product> {
* @return * @return
*/ */
List<ProductListResp> selectList(ProductListReq productListReq); List<ProductListResp> selectList(ProductListReq productListReq);
/**
*
* @return
*/
List<ProductListResp> selecthostportList();
} }

View File

@ -11,6 +11,7 @@ import com.muyu.common.core.utils.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Authorweiran * @Authorweiran
@ -41,6 +42,36 @@ public class ProductApiServiceImpl extends ServiceImpl<ProductApiMapper, Product
} }
/**
*
* @param productSales
* @param limit
* @return
*/
/**
*
*
*
* @return
*/
@Override
public List<ProductListResp> selecthostportList() {
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
//按销量降序排序
queryWrapper.orderByDesc(Product::getProductSales);
//限制返回的结果数量为5
queryWrapper.last("limit "+5);
List<Product> products = this.list(queryWrapper);
List<ProductListResp> productListResps = products.stream()
.map(product-> ProductListResp.productListRespbuild(product)) // 静态方法引用
.collect(Collectors.toList());
return productListResps;
}