feat():新增热点功能
parent
294c87aba4
commit
c38e3b13a5
|
@ -45,6 +45,10 @@ public class ProductListResp {
|
|||
*产品上架状态(是否上架 0未上架 1已上架)
|
||||
*/
|
||||
private Integer productState;
|
||||
/**
|
||||
* 产品销量
|
||||
*/
|
||||
private Integer productSales;
|
||||
|
||||
@Schema(description = "创建人",defaultValue = "muyu",type = "String")
|
||||
private String createBy;
|
||||
|
@ -67,6 +71,7 @@ public class ProductListResp {
|
|||
.productPrice(product.getProductPrice())
|
||||
.productContent(product.getProductContent())
|
||||
.productState(product.getProductState())
|
||||
.productSales(product.getProductSales())
|
||||
.createBy(product.getCreateBy())
|
||||
.createTime(product.getCreateTime())
|
||||
.build();
|
||||
|
|
|
@ -40,7 +40,7 @@ public class FindCustomerMeaasgeController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/findListByuserCard/{idCard}")
|
||||
@Operation(summary = "查询客户信息",description = "根据身份证号查询客户信息")
|
||||
@Operation(summary = "身份证号查询客户信息",description = "根据身份证号查询客户信息")
|
||||
public Result<Customer> findListByuserCard(@Validated @PathVariable String idCard){
|
||||
return Result.success(findCustomerMeaasgeService.findListByuserCard(idCard));
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class FindCustomerMeaasgeController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/findListByuserPhone/{tel}")
|
||||
@Operation(summary = "查询客户信息",description = "根据手机号查询客户信息")
|
||||
@Operation(summary = "手机号查询客户信息",description = "根据手机号查询客户信息")
|
||||
public Result<Customer> findListByuserPhone(@Validated @PathVariable String tel){
|
||||
return Result.success(findCustomerMeaasgeService.findListByuserPhone(tel));
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -22,4 +22,12 @@ public interface ProductApiService extends IService<Product> {
|
|||
* @return
|
||||
*/
|
||||
List<ProductListResp> selectList(ProductListReq productListReq);
|
||||
|
||||
/**
|
||||
* 查询热点产品
|
||||
* @return
|
||||
*/
|
||||
List<ProductListResp> selecthostportList();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.muyu.common.core.utils.StringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue