店铺新增商店权限数据

This commit is contained in:
liyj 2025-06-14 09:01:22 +08:00
parent 06963c2fda
commit 15e8e1d641
7 changed files with 31 additions and 5 deletions

View File

@ -1,9 +1,11 @@
package com.suisung.mall.shop.base.controller.admin; package com.suisung.mall.shop.base.controller.admin;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.modules.base.ShopBaseProductBrand; 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.service.impl.BaseControllerImpl;
import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService; import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
@ -17,6 +19,8 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays; import java.util.Arrays;
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
/** /**
* <p> * <p>
* 品牌表 - 540 前端控制器 * 品牌表 - 540 前端控制器
@ -54,6 +58,8 @@ public class ShopBaseProductBrandController extends BaseControllerImpl {
@RequestMapping(value = "/brands", method = RequestMethod.GET) @RequestMapping(value = "/brands", method = RequestMethod.GET)
public CommonResult getList(@RequestParam(name = "brand_name", required = false) String brand_name) { public CommonResult getList(@RequestParam(name = "brand_name", required = false) String brand_name) {
QueryWrapper<ShopBaseProductBrand> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopBaseProductBrand> queryWrapper = new QueryWrapper<>();
Integer store_id = Convert.toInt(getCurrentUser().getStore_id());
queryWrapper.eq("store_id", store_id);
queryWrapper.eq("brand_enable", 1); queryWrapper.eq("brand_enable", 1);
queryWrapper.orderByAsc("brand_id"); queryWrapper.orderByAsc("brand_id");
if (StrUtil.isNotEmpty(brand_name)) { if (StrUtil.isNotEmpty(brand_name)) {
@ -65,6 +71,8 @@ public class ShopBaseProductBrandController extends BaseControllerImpl {
@ApiOperation(value = "品牌表 - 540-编辑", notes = "品牌表 - 540-编辑") @ApiOperation(value = "品牌表 - 540-编辑", notes = "品牌表 - 540-编辑")
@RequestMapping(value = "/edit", method = RequestMethod.POST) @RequestMapping(value = "/edit", method = RequestMethod.POST)
public CommonResult edit(ShopBaseProductBrand shopBaseProductBrand) { public CommonResult edit(ShopBaseProductBrand shopBaseProductBrand) {
Integer store_id = Convert.toInt(getCurrentUser().getStore_id());
shopBaseProductBrand.setStore_id(store_id);
return CommonResult.success(shopBaseProductBrandService.saveOrUpdateBrand(shopBaseProductBrand)); return CommonResult.success(shopBaseProductBrandService.saveOrUpdateBrand(shopBaseProductBrand));
} }
@ -100,6 +108,8 @@ public class ShopBaseProductBrandController extends BaseControllerImpl {
public CommonResult getBrandS() { public CommonResult getBrandS() {
String brand_name = getParameter("brand_name"); String brand_name = getParameter("brand_name");
QueryWrapper<ShopBaseProductBrand> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopBaseProductBrand> queryWrapper = new QueryWrapper<>();
Integer store_id = Convert.toInt(getCurrentUser().getStore_id());
queryWrapper.eq("store_id", store_id);
queryWrapper.like("brand_name", brand_name); queryWrapper.like("brand_name", brand_name);
return CommonResult.success(shopBaseProductBrandService.find(queryWrapper)); return CommonResult.success(shopBaseProductBrandService.find(queryWrapper));
} }

View File

@ -1,5 +1,6 @@
package com.suisung.mall.shop.base.controller.admin; package com.suisung.mall.shop.base.controller.admin;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.modules.base.ShopBaseProductCategory; 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.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
/** /**
* <p> * <p>
* 商品分类表-分类强调区别, 类型强调共性 前端控制器 * 商品分类表-分类强调区别, 类型强调共性 前端控制器
@ -60,6 +63,8 @@ public class ShopBaseProductCategoryController {
@RequestMapping(value = "/categoryTree", method = RequestMethod.GET) @RequestMapping(value = "/categoryTree", method = RequestMethod.GET)
public CommonResult getList(ShopBaseProductCategory category) { public CommonResult getList(ShopBaseProductCategory category) {
QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>();
String store_id = getCurrentUser().getStore_id();
queryWrapper.eq("store_id", store_id);
queryWrapper.eq("category_is_enable", 1); queryWrapper.eq("category_is_enable", 1);
Integer category_parent_id = category.getCategory_parent_id(); Integer category_parent_id = category.getCategory_parent_id();
if (category_parent_id == null) category_parent_id = 0; if (category_parent_id == null) category_parent_id = 0;
@ -82,6 +87,8 @@ public class ShopBaseProductCategoryController {
@ApiOperation(value = "商品分类表-分类强调区别, 类型强调共性-编辑", notes = "商品分类表-分类强调区别, 类型强调共性-编辑") @ApiOperation(value = "商品分类表-分类强调区别, 类型强调共性-编辑", notes = "商品分类表-分类强调区别, 类型强调共性-编辑")
@RequestMapping(value = "/edit", method = RequestMethod.POST) @RequestMapping(value = "/edit", method = RequestMethod.POST)
public CommonResult edit(ShopBaseProductCategory shopBaseProductCategory) { public CommonResult edit(ShopBaseProductCategory shopBaseProductCategory) {
String store_id = getCurrentUser().getStore_id();
shopBaseProductCategory.setStore_id(store_id);
Integer category_id = shopBaseProductCategory.getCategory_id(); Integer category_id = shopBaseProductCategory.getCategory_id();
if (category_id == null) { if (category_id == null) {
shopBaseProductCategory.setPage_id_pc(0L); shopBaseProductCategory.setPage_id_pc(0L);
@ -126,6 +133,7 @@ public class ShopBaseProductCategoryController {
@RequestMapping(value = "/tree", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/tree", method = {RequestMethod.GET, RequestMethod.POST})
public CommonResult tree(ShopBaseProductCategory category) { public CommonResult tree(ShopBaseProductCategory category) {
QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", getCurrentUser().getStore_id());
queryWrapper.orderByAsc("category_order"); queryWrapper.orderByAsc("category_order");
if (category.getCategory_parent_id() != null) { if (category.getCategory_parent_id() != null) {
queryWrapper.eq("category_parent_id", category.getCategory_parent_id()); queryWrapper.eq("category_parent_id", category.getCategory_parent_id());

View File

@ -79,7 +79,9 @@ public class ShopBaseProductTypeController {
@ApiOperation(value = "商品类型表-强调共性,类别cat是强调区别.-列表查询", notes = "商品类型表-强调共性,类别cat是强调区别.-列表查询") @ApiOperation(value = "商品类型表-强调共性,类别cat是强调区别.-列表查询", notes = "商品类型表-强调共性,类别cat是强调区别.-列表查询")
@RequestMapping(value = "/lists", method = RequestMethod.GET) @RequestMapping(value = "/lists", method = RequestMethod.GET)
public CommonResult lists() { public CommonResult lists() {
Integer store_id = Convert.toInt(getCurrentUser().getStore_id());
QueryWrapper<ShopBaseProductType> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopBaseProductType> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", store_id);
queryWrapper.orderByAsc("type_id"); queryWrapper.orderByAsc("type_id");
return CommonResult.success(shopBaseProductTypeService.find(queryWrapper)); return CommonResult.success(shopBaseProductTypeService.find(queryWrapper));
} }
@ -87,7 +89,9 @@ public class ShopBaseProductTypeController {
@ApiOperation(value = "商品类型表-强调共性,类别cat是强调区别.-列表查询", notes = "商品类型表-强调共性,类别cat是强调区别.-列表查询") @ApiOperation(value = "商品类型表-强调共性,类别cat是强调区别.-列表查询", notes = "商品类型表-强调共性,类别cat是强调区别.-列表查询")
@RequestMapping(value = "/getLists", method = RequestMethod.GET) @RequestMapping(value = "/getLists", method = RequestMethod.GET)
public CommonResult getLists() { public CommonResult getLists() {
Integer store_id = Convert.toInt(getCurrentUser().getStore_id());
QueryWrapper<ShopBaseProductType> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopBaseProductType> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", store_id);
queryWrapper.orderByAsc("type_id"); queryWrapper.orderByAsc("type_id");
queryWrapper.eq("type_is_draft", 0); queryWrapper.eq("type_is_draft", 0);
return CommonResult.success(shopBaseProductTypeService.find(queryWrapper)); return CommonResult.success(shopBaseProductTypeService.find(queryWrapper));
@ -105,6 +109,8 @@ public class ShopBaseProductTypeController {
public CommonResult edit(ShopBaseProductType shopBaseProductType) { public CommonResult edit(ShopBaseProductType shopBaseProductType) {
String type_spec_ids = shopBaseProductType.getType_spec_ids(); String type_spec_ids = shopBaseProductType.getType_spec_ids();
Integer store_id = Convert.toInt(getCurrentUser().getStore_id());
shopBaseProductType.setStore_id(store_id);
//读取当前已经存在的type_id //读取当前已经存在的type_id
Integer type_id = shopBaseProductType.getType_id(); Integer type_id = shopBaseProductType.getType_id();

View File

@ -28,7 +28,8 @@ public interface ShopBaseProductCategoryMapper extends BaseMapper<ShopBaseProduc
List<Integer> getParentCategory(@Param("category_id") Integer category_id); List<Integer> getParentCategory(@Param("category_id") Integer category_id);
/** /**
* 查询商品分类列表 * 根据商店id查询商品分类列表
* @param storeId 商店id
*/ */
List<ShopBaseProductCategory> selectCategoryList(); List<ShopBaseProductCategory> selectCategoryList(@Param("storeId") String storeId);
} }

View File

@ -52,8 +52,8 @@ public class ShopBaseProductBrandServiceImpl extends BaseServiceImpl<ShopBasePro
@Override @Override
public Map<String, List<ShopBaseProductBrand>> brandMap() { public Map<String, List<ShopBaseProductBrand>> brandMap() {
Integer store_id = Convert.toInt(getCurrentUser().getStore_id());
List<ShopBaseProductBrand> brands = find(new QueryWrapper<ShopBaseProductBrand>().eq("brand_enable", 1)); List<ShopBaseProductBrand> brands = find(new QueryWrapper<ShopBaseProductBrand>().eq("brand_enable", 1).eq("store_id", store_id));
if (CollectionUtil.isEmpty(brands)) { if (CollectionUtil.isEmpty(brands)) {
throw new ApiException(I18nUtil._("启用品牌列表为空!")); throw new ApiException(I18nUtil._("启用品牌列表为空!"));

View File

@ -940,7 +940,7 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
@Override @Override
public Map lists() { public Map lists() {
List<ShopBaseProductCategory> shopBaseProductCategories = shopBaseProductCategoryMapper.selectCategoryList(); List<ShopBaseProductCategory> shopBaseProductCategories = shopBaseProductCategoryMapper.selectCategoryList(getCurrentUser().getStore_id());
Map map = new HashMap(1); Map map = new HashMap(1);
map.put("items", shopBaseProductCategories); map.put("items", shopBaseProductCategories);
return map; return map;

View File

@ -31,6 +31,7 @@
c.category_name AS `name`, c.category_name AS `name`,
t.type_name AS `type_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 FROM shop_base_product_category c JOIN shop_base_product_type t ON c.type_id = t.type_id
where c.store_id=#{storeId}
</select> </select>
</mapper> </mapper>