Commit d0fe8625a30784eae87c8eaf0c9154dbc094eed0

Authored by boyang
1 parent 21febc88

feat: 热销商品

shop/src/main/java/com/canrd/shop/controller/ProductController.java
... ... @@ -97,6 +97,11 @@ public class ProductController {
97 97 return productService.listBySimilar(productQueryVO);
98 98 }
99 99  
  100 + @GetMapping("/hotProducts")
  101 + public ServerResult hotProducts(@Validated({OperateGroup.List.class}) ProductQueryVO productQueryVO) {
  102 + return productService.hotProducts(productQueryVO);
  103 + }
  104 +
100 105 /**
101 106 * 生成静态页面
102 107 *
... ...
shop/src/main/java/com/canrd/shop/service/ProductService.java
... ... @@ -65,4 +65,6 @@ public interface ProductService extends IService<ProductDO> {
65 65 ServerResult categorySearch(ProductQueryVO productQueryVO);
66 66  
67 67 ServerResult chatgpt(ProductQueryVO productQueryVO);
  68 +
  69 + ServerResult hotProducts(ProductQueryVO productQueryVO);
68 70 }
... ...
shop/src/main/java/com/canrd/shop/service/impl/ProductServiceImpl.java
... ... @@ -628,6 +628,18 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, ProductDO> im
628 628 return null;
629 629 }
630 630  
  631 + @Override
  632 + public ServerResult hotProducts(ProductQueryVO productQueryVO) {
  633 + QueryWrapper<ProductQueryVO> queryWrapper = new QueryWrapper<>();
  634 + queryWrapper.eq("isHot", true)
  635 + .eq("isMarketable",true); // 条件:isHot = true
  636 +
  637 + Page page = new Page<>(productQueryVO.getPageNo(), productQueryVO.getPageSize());
  638 + IPage<ProductDO> iPage = productMapper.queryAll(page,queryWrapper);
  639 + productQueryVO.setTotal(Long.valueOf(iPage.getTotal()).intValue());
  640 + return ServerResult.success().setData(PageUtils.getPageReturn(iPage.getRecords(), productQueryVO));
  641 + }
  642 +
631 643 private String translateHtmlOneProductFieldByChatGpt2(String source) throws IOException, InterruptedException {
632 644 try{
633 645 Thread.sleep(1000 * 20);
... ...