소스 검색

修复bug

赵冬冬 4 년 전
부모
커밋
8d884cf931

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1224 - 0
api/林产品信息发布平台.postman_collection.json


+ 4 - 3
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/controller/PmsProductCategoryController.java

@@ -1,5 +1,6 @@
 package com.hwrj.cloud.admin.controller;
 
+import com.github.pagehelper.PageInfo;
 import com.hwrj.cloud.common.api.CommonPage;
 import com.hwrj.cloud.common.api.CommonResult;
 import com.hwrj.cloud.admin.dto.PmsProductCategoryParam;
@@ -58,11 +59,11 @@ public class PmsProductCategoryController {
     @ApiOperation("分页查询商品分类")
     @RequestMapping(value = "/list/{parentId}", method = RequestMethod.GET)
     @ResponseBody
-    public CommonResult<CommonPage<PmsProductCategory>> getList(@PathVariable Long parentId,
+    public CommonResult getList(@PathVariable Long parentId,
                                                                 @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
-        List<PmsProductCategory> productCategoryList = productCategoryService.getList(parentId, pageSize, pageNum);
-        return CommonResult.success(CommonPage.restPage(productCategoryList));
+        PageInfo<PmsProductCategory> productCategoryList = productCategoryService.getList(parentId, pageSize, pageNum);
+        return CommonResult.success(productCategoryList);
     }
 
     @ApiOperation("根据id获取商品分类")

+ 3 - 0
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/dao/PmsProductCategoryDao.java

@@ -1,6 +1,7 @@
 package com.hwrj.cloud.admin.dao;
 
 import com.hwrj.cloud.admin.dto.PmsProductCategoryWithChildrenItem;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -15,4 +16,6 @@ public interface PmsProductCategoryDao {
     List<PmsProductCategoryWithChildrenItem> listWithChildren();
 
     long deleteCheck(Long id);
+
+    Integer ProductNum(@Param("parentId") Long parentId,@Param("id") Long id);
 }

+ 2 - 1
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/service/PmsProductCategoryService.java

@@ -1,5 +1,6 @@
 package com.hwrj.cloud.admin.service;
 
+import com.github.pagehelper.PageInfo;
 import com.hwrj.cloud.admin.dto.PmsProductCategoryParam;
 import com.hwrj.cloud.admin.dto.PmsProductCategoryWithChildrenItem;
 import com.hwrj.cloud.admin.model.PmsProductCategory;
@@ -27,7 +28,7 @@ public interface PmsProductCategoryService {
     /**
      * 分页获取商品分类
      */
-    List<PmsProductCategory> getList(Long parentId, Integer pageSize, Integer pageNum);
+    PageInfo<PmsProductCategory> getList(Long parentId, Integer pageSize, Integer pageNum);
 
     /**
      * 删除商品分类

+ 13 - 4
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/service/impl/PmsProductCategoryServiceImpl.java

@@ -1,6 +1,7 @@
 package com.hwrj.cloud.admin.service.impl;
 
 import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.hwrj.cloud.admin.dao.PmsProductCategoryAttributeRelationDao;
 import com.hwrj.cloud.admin.dao.PmsProductCategoryDao;
 import com.hwrj.cloud.admin.dto.PmsProductCategoryParam;
@@ -94,13 +95,21 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
     }
 
     @Override
-    public List<PmsProductCategory> getList(Long parentId, Integer pageSize, Integer pageNum) {
+    public PageInfo<PmsProductCategory> getList(Long parentId, Integer pageSize, Integer pageNum) {
         PageHelper.startPage(pageNum, pageSize);
         PmsProductCategoryExample example = new PmsProductCategoryExample();
-        example.setOrderByClause("sort desc");
-        example.setOrderByClause("id desc");
+        example.setOrderByClause("sort asc");
         example.createCriteria().andParentIdEqualTo(parentId);
-        return productCategoryMapper.selectByExample(example);
+        List<PmsProductCategory> pmsProductCategories = productCategoryMapper.selectByExample(example);
+        PageInfo<PmsProductCategory> pageInfo = new PageInfo(pmsProductCategories);
+
+        List<PmsProductCategory> list = pageInfo.getList();
+        for (PmsProductCategory pmsProductCategory : list) {
+
+            Integer productNum =  productCategoryDao.ProductNum(parentId,pmsProductCategory.getId());
+            pmsProductCategory.setProductCount(productNum);
+        }
+        return  pageInfo;
     }
     @Autowired
     private PmsProductCategoryDao pmsProductCategoryDao;

+ 3 - 2
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/util/UploadFileUtil.java

@@ -37,14 +37,15 @@ public class UploadFileUtil {
 
     public String uploadQiNiuFiles(@RequestParam("file") MultipartFile file, String path){
         String contentType = file.getContentType();
+        String[] split = contentType.split("/");
+        path = path+"."+split[1];
         //构建一个带指定对象的配置类
         Configuration cof = new Configuration(Zone.autoZone());
-        String s = path;
         UploadManager uploadManager = new UploadManager(cof);
         String uploadToken = getUploadToken();
         DefaultPutRet defaultPutRet = null;
         try{
-            Response response = uploadManager.put(file.getInputStream(), s, uploadToken, null, null);
+            Response response = uploadManager.put(file.getInputStream(), path, uploadToken, null, null);
             defaultPutRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class);
             log.info(JSONObject.toJSONString(defaultPutRet));
             return url+path;

+ 16 - 0
forest-admin/admin-server/src/main/resources/dao/PmsProductCategoryDao.xml

@@ -53,4 +53,20 @@
                     )
             ) tmp
     </select>
+    <select id="ProductNum" resultType="java.lang.Integer">
+        SELECT
+            COUNT(0)
+        FROM
+            pms_product a
+        WHERE 1=1
+            <choose>
+                <when test="parentId ==0 or parentId =='0'">
+                    and a.product_big_category_id = #{id}
+                </when>
+                <otherwise>
+                    and a.product_category_id = #{id}
+                </otherwise>
+            </choose>
+
+        </select>
 </mapper>

+ 3 - 0
forest-portal/portal-server/src/main/java/com/hwrj/cloud/portal/service/impl/PmsPortalProductServiceImpl.java

@@ -113,6 +113,8 @@ public class PmsPortalProductServiceImpl implements PmsPortalProductService {
     @Override
     public List<PmsProductCategoryNode> categoryTreeList() {
         PmsProductCategoryExample example = new PmsProductCategoryExample();
+        PmsProductCategoryExample.Criteria criteria = example.createCriteria();
+        criteria.andShowStatusEqualTo(1);
         List<PmsProductCategory> allList = productCategoryMapper.selectByExample(example);
         example.setOrderByClause("sort ASC");
         List<PmsProductCategoryNode> result = allList.stream()
@@ -142,6 +144,7 @@ public class PmsPortalProductServiceImpl implements PmsPortalProductService {
             PmsProductCategoryExample.Criteria criteria1 = example1.createCriteria();
             ArrayList<Long> longs = new ArrayList<>(collect.keySet());
             criteria1.andIdIn(longs);
+            criteria1.andNavStatusEqualTo(1);
             List<PmsProductCategory> example2 = productCategoryMapper.selectByExample(example1);
             pms.addAll(example2);