Browse Source

fixed 根据商品分类查询商品

fushengqian 1 year ago
parent
commit
115f345a0a

+ 4 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java

@@ -111,6 +111,10 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
         if (StringUtils.isNotBlank(type)) {
             lambdaQueryWrapper.eq(MtGoods::getType, type);
         }
+        String cateId = paginationRequest.getSearchParams().get("cateId") == null ? "" : paginationRequest.getSearchParams().get("cateId").toString();
+        if (StringUtils.isNotBlank(cateId)) {
+            lambdaQueryWrapper.eq(MtGoods::getCateId, cateId);
+        }
         String hasStock = paginationRequest.getSearchParams().get("stock") == null ? "" : paginationRequest.getSearchParams().get("stock").toString();
         if (StringUtils.isNotBlank(hasStock)) {
             if (hasStock.equals(YesOrNoEnum.YES.getKey())) {

+ 19 - 3
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendGoodsController.java

@@ -75,8 +75,8 @@ public class BackendGoodsController extends BaseController {
      * 分页查询商品列表
      *
      * @param request
-     * @return
      * @throws BusinessCheckException
+     * @return
      */
     @ApiOperation(value = "分页查询商品列表")
     @RequestMapping(value = "/list", method = RequestMethod.GET)
@@ -93,6 +93,7 @@ public class BackendGoodsController extends BaseController {
         String status = request.getParameter("status");
         String searchStoreId = request.getParameter("storeId");
         String stock = request.getParameter("stock");
+        String cateId = request.getParameter("cateId");
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         if (accountInfo == null) {
@@ -123,6 +124,9 @@ public class BackendGoodsController extends BaseController {
         if (StringUtil.isNotEmpty(type)) {
             params.put("type", type);
         }
+        if (StringUtil.isNotEmpty(cateId)) {
+            params.put("cateId", cateId);
+        }
         if (StringUtil.isNotEmpty(goodsNo)) {
             params.put("goodsNo", goodsNo);
         }
@@ -159,10 +163,21 @@ public class BackendGoodsController extends BaseController {
         }
         List<MtStore> storeList = storeService.queryStoresByParams(paramsStore);
 
+        Map<String, Object> cateParam = new HashMap<>();
+        cateParam.put("status", StatusEnum.ENABLED.getKey());
+        if (accountInfo.getMerchantId() != null && accountInfo.getMerchantId() > 0) {
+            cateParam.put("merchantId", accountInfo.getMerchantId());
+        }
+        if (storeId != null && storeId > 0) {
+            cateParam.put("storeId", storeId.toString());
+        }
+        List<MtGoodsCate> cateList = cateService.queryCateListByParams(cateParam);
+
         Map<String, Object> result = new HashMap<>();
         result.put("paginationResponse", paginationResponse);
         result.put("typeList", typeList);
         result.put("storeList", storeList);
+        result.put("cateList", cateList);
 
         return getSuccessResult(result);
     }
@@ -171,13 +186,14 @@ public class BackendGoodsController extends BaseController {
      * 删除商品
      *
      * @param request
+     * @param goodsId 商品ID
      * @return
      */
     @ApiOperation(value = "删除商品")
     @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('goods:goods:edit')")
-    public ResponseObject delete(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
+    public ResponseObject delete(HttpServletRequest request, @PathVariable("id") Integer goodsId) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
@@ -185,7 +201,7 @@ public class BackendGoodsController extends BaseController {
             return getFailureResult(1001, "请先登录");
         }
         String operator = accountInfo.getAccountName();
-        goodsService.deleteGoods(id, operator);
+        goodsService.deleteGoods(goodsId, operator);
         return getSuccessResult(true);
     }