Browse Source

添加分销模块, 并且修改菜单权限

gaohp 11 months ago
parent
commit
9e0a540301

+ 27 - 0
feifan-module-distri/pom.xml

@@ -0,0 +1,27 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>cn.newfeifan.zx</groupId>
+        <artifactId>feifan</artifactId>
+        <version>${revision}</version>
+    </parent>
+
+    <artifactId>feifan-module-distri</artifactId>
+    <packaging>pom</packaging>
+
+    <name>${project.artifactId}</name>
+    <url>http://maven.apache.org</url>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+<description> <!-- 4. 新增 description 为该模块的描述 -->
+demo 模块,主要实现 XXX、YYY、ZZZ 等功能。
+</description>
+
+
+
+
+
+</project>

+ 1 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/config/vo/TradeConfigSaveReqVO.java

@@ -11,4 +11,5 @@ import lombok.ToString;
 @ToString(callSuper = true)
 public class TradeConfigSaveReqVO extends TradeConfigBaseVO {
 
+
 }

+ 4 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/config/TradeConfigDO.java

@@ -115,4 +115,8 @@ public class TradeConfigDO extends BaseDO {
     @TableField(typeHandler = IntegerListTypeHandler.class)
     private List<Integer> brokerageWithdrawTypes;
 
+
+
+
+
 }

+ 6 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/auth/AuthController.java

@@ -25,6 +25,8 @@ import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.Parameters;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -63,6 +65,9 @@ public class AuthController {
     @Resource
     private SecurityProperties securityProperties;
 
+
+
+
     @PostMapping("/login")
     @PermitAll
     @Operation(summary = "使用账号密码登录")
@@ -114,6 +119,7 @@ public class AuthController {
         Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId));
         List<MenuDO> menuList = menuService.getMenuList(menuIds);
         menuList.removeIf(menu -> !CommonStatusEnum.ENABLE.getStatus().equals(menu.getStatus())); // 移除禁用的菜单
+        menuList.removeIf(menu -> menu.getCategoryId() == 2L); // 移除禁用的菜单
 
         // 2. 拼接结果返回
         return success(AuthConvert.INSTANCE.convert(user, roles, menuList));

+ 3 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/user/vo/user/UserPageReqVO.java

@@ -44,4 +44,7 @@ public class UserPageReqVO extends PageParam {
     @Schema(description = "店铺id", example = "9887")
     private Long shopId;
 
+
+
+
 }

+ 4 - 2
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/dal/mysql/permission/MenuMapper.java

@@ -4,6 +4,7 @@ import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
 import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.newfeifan.mall.module.system.controller.admin.permission.vo.menu.MenuListReqVO;
 import cn.newfeifan.mall.module.system.dal.dataobject.permission.MenuDO;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -11,8 +12,9 @@ import java.util.List;
 @Mapper
 public interface MenuMapper extends BaseMapperX<MenuDO> {
 
-    default MenuDO selectByParentIdAndName(Long parentId, String name) {
-        return selectOne(MenuDO::getParentId, parentId, MenuDO::getName, name);
+    default MenuDO selectByParentIdAndName(Long category, Long parentId, String name) {
+        return selectOne(new LambdaQueryWrapperX<MenuDO>().eqIfPresent(MenuDO::getCategoryId, category).eqIfPresent(MenuDO::getParentId, parentId)
+                .eqIfPresent(MenuDO::getName, name));
     }
 
     default Long selectCountByParentId(Long parentId) {

+ 15 - 10
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/service/permission/MenuServiceImpl.java

@@ -2,6 +2,7 @@ package cn.newfeifan.mall.module.system.service.permission;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.newfeifan.mall.module.system.controller.admin.permission.vo.menu.MenuSaveVO;
 import cn.newfeifan.mall.module.system.controller.admin.permission.vo.menu.MenuListReqVO;
 import cn.newfeifan.mall.module.system.dal.dataobject.permission.MenuDO;
@@ -9,6 +10,7 @@ import cn.newfeifan.mall.module.system.dal.mysql.permission.MenuMapper;
 import cn.newfeifan.mall.module.system.dal.redis.RedisKeyConstants;
 import cn.newfeifan.mall.module.system.enums.permission.MenuTypeEnum;
 import cn.newfeifan.mall.module.system.service.tenant.TenantService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.annotations.VisibleForTesting;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.cache.annotation.CacheEvict;
@@ -48,9 +50,9 @@ public class MenuServiceImpl implements MenuService {
             condition = "#createReqVO.permission != null")
     public Long createMenu(MenuSaveVO createReqVO) {
         // 校验父菜单存在
-        validateParentMenu(createReqVO.getParentId(), null);
+        validateParentMenu(createReqVO.getParentId(), null, createReqVO.getCategoryId());
         // 校验菜单(自己)
-        validateMenu(createReqVO.getParentId(), createReqVO.getName(), null);
+        validateMenu(createReqVO.getCategoryId(),createReqVO.getParentId(), createReqVO.getName(), null);
 
         // 插入数据库
         MenuDO menu = BeanUtils.toBean(createReqVO, MenuDO.class);
@@ -69,9 +71,9 @@ public class MenuServiceImpl implements MenuService {
             throw exception(MENU_NOT_EXISTS);
         }
         // 校验父菜单存在
-        validateParentMenu(updateReqVO.getParentId(), updateReqVO.getId());
+        validateParentMenu(updateReqVO.getParentId(), updateReqVO.getId(),updateReqVO.getCategoryId());
         // 校验菜单(自己)
-        validateMenu(updateReqVO.getParentId(), updateReqVO.getName(), updateReqVO.getId());
+        validateMenu(updateReqVO.getCategoryId(),updateReqVO.getParentId(), updateReqVO.getName(), updateReqVO.getId());
 
         // 更新到数据库
         MenuDO updateObj = BeanUtils.toBean(updateReqVO, MenuDO.class);
@@ -140,11 +142,12 @@ public class MenuServiceImpl implements MenuService {
      * 2. 父菜单不存在
      * 3. 父菜单必须是 {@link MenuTypeEnum#MENU} 菜单类型
      *
-     * @param parentId 父菜单编号
-     * @param childId  当前菜单编号
+     * @param parentId   父菜单编号
+     * @param childId    当前菜单编号
+     * @param categoryId
      */
     @VisibleForTesting
-    void validateParentMenu(Long parentId, Long childId) {
+    void validateParentMenu(Long parentId, Long childId, Long categoryId) {
         if (parentId == null || ID_ROOT.equals(parentId)) {
             return;
         }
@@ -152,7 +155,9 @@ public class MenuServiceImpl implements MenuService {
         if (parentId.equals(childId)) {
             throw exception(MENU_PARENT_ERROR);
         }
-        MenuDO menu = menuMapper.selectById(parentId);
+//        MenuDO menu = menuMapper.selectById(parentId);
+        MenuDO menu = menuMapper.selectOne(new LambdaQueryWrapperX<MenuDO>().eqIfPresent(MenuDO::getParentId,parentId)
+                .eqIfPresent(MenuDO::getCategoryId,categoryId));
         // 父菜单不存在
         if (menu == null) {
             throw exception(MENU_PARENT_NOT_EXISTS);
@@ -174,8 +179,8 @@ public class MenuServiceImpl implements MenuService {
      * @param id       菜单编号
      */
     @VisibleForTesting
-    void validateMenu(Long parentId, String name, Long id) {
-        MenuDO menu = menuMapper.selectByParentIdAndName(parentId, name);
+    void validateMenu(Long category,Long parentId, String name, Long id) {
+        MenuDO menu = menuMapper.selectByParentIdAndName(category,parentId, name);
         if (menu == null) {
             return;
         }

+ 1 - 0
pom.xml

@@ -22,6 +22,7 @@
         <module>feifan-module-pay</module>
         <module>feifan-module-mall</module>
         <module>feifan-module-sale</module>
+        <module>feifan-module-distri</module>
         <!--        <module>feifan-module-crm</module>-->
         <!-- 示例项目 -->
 <!--        <module>feifan-example</module>-->