From 11eb0165ce1091a2bf4dd723135c7de1e1c98bb0 Mon Sep 17 00:00:00 2001 From: liyj <1617420630@qq.com> Date: Sat, 14 Jun 2025 09:01:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=96=B0=E5=A2=9E=E5=95=86?= =?UTF-8?q?=E5=BA=97=E6=9D=83=E9=99=90=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/ShopBaseProductBrandController.java | 10 ++++++++++ .../admin/ShopBaseProductCategoryController.java | 8 ++++++++ .../admin/ShopBaseProductTypeController.java | 6 ++++++ .../base/mapper/ShopBaseProductCategoryMapper.java | 5 +++-- .../service/impl/ShopBaseProductBrandServiceImpl.java | 4 ++-- .../impl/ShopBaseProductCategoryServiceImpl.java | 2 +- .../mapper/base/ShopBaseProductCategoryMapper.xml | 1 + 7 files changed, 31 insertions(+), 5 deletions(-) diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductBrandController.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductBrandController.java index affc896b..598bb1c2 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductBrandController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductBrandController.java @@ -1,9 +1,11 @@ package com.suisung.mall.shop.base.controller.admin; +import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.base.ShopBaseProductBrand; +import com.suisung.mall.common.modules.base.ShopBaseProductType; import com.suisung.mall.common.service.impl.BaseControllerImpl; import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.shop.base.service.ShopBaseProductBrandService; @@ -17,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController; import java.util.Arrays; +import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser; + /** *

* 品牌表 - 540 前端控制器 @@ -54,6 +58,8 @@ public class ShopBaseProductBrandController extends BaseControllerImpl { @RequestMapping(value = "/brands", method = RequestMethod.GET) public CommonResult getList(@RequestParam(name = "brand_name", required = false) String brand_name) { QueryWrapper queryWrapper = new QueryWrapper<>(); + Integer store_id = Convert.toInt(getCurrentUser().getStore_id()); + queryWrapper.eq("store_id", store_id); queryWrapper.eq("brand_enable", 1); queryWrapper.orderByAsc("brand_id"); if (StrUtil.isNotEmpty(brand_name)) { @@ -65,6 +71,8 @@ public class ShopBaseProductBrandController extends BaseControllerImpl { @ApiOperation(value = "品牌表 - 540-编辑", notes = "品牌表 - 540-编辑") @RequestMapping(value = "/edit", method = RequestMethod.POST) public CommonResult edit(ShopBaseProductBrand shopBaseProductBrand) { + Integer store_id = Convert.toInt(getCurrentUser().getStore_id()); + shopBaseProductBrand.setStore_id(store_id); return CommonResult.success(shopBaseProductBrandService.saveOrUpdateBrand(shopBaseProductBrand)); } @@ -100,6 +108,8 @@ public class ShopBaseProductBrandController extends BaseControllerImpl { public CommonResult getBrandS() { String brand_name = getParameter("brand_name"); QueryWrapper queryWrapper = new QueryWrapper<>(); + Integer store_id = Convert.toInt(getCurrentUser().getStore_id()); + queryWrapper.eq("store_id", store_id); queryWrapper.like("brand_name", brand_name); return CommonResult.success(shopBaseProductBrandService.find(queryWrapper)); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java index dde4b34e..c288d60d 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java @@ -1,5 +1,6 @@ package com.suisung.mall.shop.base.controller.admin; +import cn.hutool.core.convert.Convert; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.base.ShopBaseProductCategory; @@ -13,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser; + /** *

* 商品分类表-分类强调区别, 类型强调共性 前端控制器 @@ -60,6 +63,8 @@ public class ShopBaseProductCategoryController { @RequestMapping(value = "/categoryTree", method = RequestMethod.GET) public CommonResult getList(ShopBaseProductCategory category) { QueryWrapper queryWrapper = new QueryWrapper<>(); + String store_id = getCurrentUser().getStore_id(); + queryWrapper.eq("store_id", store_id); queryWrapper.eq("category_is_enable", 1); Integer category_parent_id = category.getCategory_parent_id(); if (category_parent_id == null) category_parent_id = 0; @@ -82,6 +87,8 @@ public class ShopBaseProductCategoryController { @ApiOperation(value = "商品分类表-分类强调区别, 类型强调共性-编辑", notes = "商品分类表-分类强调区别, 类型强调共性-编辑") @RequestMapping(value = "/edit", method = RequestMethod.POST) public CommonResult edit(ShopBaseProductCategory shopBaseProductCategory) { + String store_id = getCurrentUser().getStore_id(); + shopBaseProductCategory.setStore_id(store_id); Integer category_id = shopBaseProductCategory.getCategory_id(); if (category_id == null) { shopBaseProductCategory.setPage_id_pc(0L); @@ -126,6 +133,7 @@ public class ShopBaseProductCategoryController { @RequestMapping(value = "/tree", method = {RequestMethod.GET, RequestMethod.POST}) public CommonResult tree(ShopBaseProductCategory category) { QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("store_id", getCurrentUser().getStore_id()); queryWrapper.orderByAsc("category_order"); if (category.getCategory_parent_id() != null) { queryWrapper.eq("category_parent_id", category.getCategory_parent_id()); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductTypeController.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductTypeController.java index 91874bb6..7371cb42 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductTypeController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductTypeController.java @@ -79,7 +79,9 @@ public class ShopBaseProductTypeController { @ApiOperation(value = "商品类型表-强调共性,类别cat是强调区别.-列表查询", notes = "商品类型表-强调共性,类别cat是强调区别.-列表查询") @RequestMapping(value = "/lists", method = RequestMethod.GET) public CommonResult lists() { + Integer store_id = Convert.toInt(getCurrentUser().getStore_id()); QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("store_id", store_id); queryWrapper.orderByAsc("type_id"); return CommonResult.success(shopBaseProductTypeService.find(queryWrapper)); } @@ -87,7 +89,9 @@ public class ShopBaseProductTypeController { @ApiOperation(value = "商品类型表-强调共性,类别cat是强调区别.-列表查询", notes = "商品类型表-强调共性,类别cat是强调区别.-列表查询") @RequestMapping(value = "/getLists", method = RequestMethod.GET) public CommonResult getLists() { + Integer store_id = Convert.toInt(getCurrentUser().getStore_id()); QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("store_id", store_id); queryWrapper.orderByAsc("type_id"); queryWrapper.eq("type_is_draft", 0); return CommonResult.success(shopBaseProductTypeService.find(queryWrapper)); @@ -105,6 +109,8 @@ public class ShopBaseProductTypeController { public CommonResult edit(ShopBaseProductType shopBaseProductType) { String type_spec_ids = shopBaseProductType.getType_spec_ids(); + Integer store_id = Convert.toInt(getCurrentUser().getStore_id()); + shopBaseProductType.setStore_id(store_id); //读取当前已经存在的type_id Integer type_id = shopBaseProductType.getType_id(); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/mapper/ShopBaseProductCategoryMapper.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/mapper/ShopBaseProductCategoryMapper.java index cadac33f..99adbe81 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/mapper/ShopBaseProductCategoryMapper.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/mapper/ShopBaseProductCategoryMapper.java @@ -28,7 +28,8 @@ public interface ShopBaseProductCategoryMapper extends BaseMapper getParentCategory(@Param("category_id") Integer category_id); /** - * 查询商品分类列表 + * 根据商店id查询商品分类列表 + * @param storeId 商店id */ - List selectCategoryList(); + List selectCategoryList(@Param("storeId") String storeId); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductBrandServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductBrandServiceImpl.java index 3b9213c9..30294a69 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductBrandServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductBrandServiceImpl.java @@ -52,8 +52,8 @@ public class ShopBaseProductBrandServiceImpl extends BaseServiceImpl> brandMap() { - - List brands = find(new QueryWrapper().eq("brand_enable", 1)); + Integer store_id = Convert.toInt(getCurrentUser().getStore_id()); + List brands = find(new QueryWrapper().eq("brand_enable", 1).eq("store_id", store_id)); if (CollectionUtil.isEmpty(brands)) { throw new ApiException(I18nUtil._("启用品牌列表为空!")); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductCategoryServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductCategoryServiceImpl.java index 90af0436..6498635a 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductCategoryServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductCategoryServiceImpl.java @@ -940,7 +940,7 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl shopBaseProductCategories = shopBaseProductCategoryMapper.selectCategoryList(); + List shopBaseProductCategories = shopBaseProductCategoryMapper.selectCategoryList(getCurrentUser().getStore_id()); Map map = new HashMap(1); map.put("items", shopBaseProductCategories); return map; diff --git a/mall-shop/src/main/resources/mapper/base/ShopBaseProductCategoryMapper.xml b/mall-shop/src/main/resources/mapper/base/ShopBaseProductCategoryMapper.xml index 8ce1ca4d..9559953b 100644 --- a/mall-shop/src/main/resources/mapper/base/ShopBaseProductCategoryMapper.xml +++ b/mall-shop/src/main/resources/mapper/base/ShopBaseProductCategoryMapper.xml @@ -31,6 +31,7 @@ c.category_name AS `name`, t.type_name AS `type_name` FROM shop_base_product_category c JOIN shop_base_product_type t ON c.type_id = t.type_id + where c.store_id=#{storeId}