Jelajahi Sumber

采美百科数据part2

Aslee 3 tahun lalu
induk
melakukan
dc90c7ce5e

+ 24 - 4
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -378,14 +378,34 @@ public class ProductPageApi {
     /**
      * 采美百科产品仪器页面数据
      */
+    @ApiOperation("采美百科产品仪器页面数据")
+    @ApiImplicitParam(required = true, name = "commodityType", value = "商品类型:1产品,2仪器")
+    @GetMapping("/baike/page")
+    public ResponseJson<List<BaikeTypeVo>> getBaikePageData(Integer commodityType){
+        if (null == commodityType) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return pageService.getBaikePageData(commodityType);
+    }
+
+    /**
+     * 采美百科产品仪器分类数据
+     */
     @ApiOperation("采美百科产品仪器分类数据")
-    @ApiImplicitParam(required = false, name = "commodityType", value = "商品类型:1产品,2仪器")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "typeId", value = "分类id"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
+    })
     @GetMapping("/baike/type")
-    public ResponseJson<List<BaikeTypeVo>> getBaikeTypeData(Integer commodityType){
-        if (null == commodityType) {
+    public ResponseJson<PaginationVo<BaikeProductVo>> getBaikeTypeData(Integer typeId,
+                                                                    @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                    @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+        if (null == typeId) {
             return ResponseJson.error("参数异常", null);
         }
-        return pageService.getBaikeTypeData(commodityType);
+        return pageService.getBaikeTypeData(typeId, pageNum, pageSize);
     }
 
+
 }

+ 9 - 1
src/main/java/com/caimei365/commodity/service/PageService.java

@@ -204,5 +204,13 @@ public interface PageService {
      * 采美百科产品仪器页面数据
      * @param commodityType 商品类型:1产品,2仪器
      */
-    ResponseJson<List<BaikeTypeVo>> getBaikeTypeData(Integer commodityType);
+    ResponseJson<List<BaikeTypeVo>> getBaikePageData(Integer commodityType);
+
+    /**
+     * 采美百科产品仪器分类数据
+     *
+     * @param typeId 分类id
+     * @return
+     */
+    ResponseJson<PaginationVo<BaikeProductVo>> getBaikeTypeData(Integer typeId, int pageNum, int pageSize);
 }

+ 15 - 3
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -21,8 +21,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -1219,7 +1217,7 @@ public class PageServiceImpl implements PageService {
     }
 
     @Override
-    public ResponseJson<List<BaikeTypeVo>> getBaikeTypeData(Integer commodityType) {
+    public ResponseJson<List<BaikeTypeVo>> getBaikePageData(Integer commodityType) {
         // 分类列表
         List<BaikeTypeVo> baikeTypeList = pageMapper.getBaikeTypeList(commodityType);
         baikeTypeList.forEach(baikeType->{
@@ -1234,4 +1232,18 @@ public class PageServiceImpl implements PageService {
         });
         return ResponseJson.success(baikeTypeList);
     }
+
+    @Override
+    public ResponseJson<PaginationVo<BaikeProductVo>> getBaikeTypeData(Integer typeId, int pageNum, int pageSize) {
+        // 产品/仪器列表
+        PageHelper.startPage(pageNum, pageSize);
+        List<BaikeProductVo> productList = pageMapper.getBaikeTypeProducts(typeId);
+        productList.forEach(product -> {
+            // 问题列表
+            List<String> questionList = pageMapper.getBaikeQuestionList(product.getProductId());
+            product.setQuestionList(questionList);
+        });
+        PaginationVo<BaikeProductVo> pageData = new PaginationVo<>(productList);
+        return ResponseJson.success(pageData);
+    }
 }