From c66f3ca48216decddb32a7ad3fdde6bdfe1c055c Mon Sep 17 00:00:00 2001
From: Jay <csj123456>
Date: 星期三, 16 十月 2024 15:31:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/permission/PermissionServiceImpl.java |   60 ++++++++++++++++++++++++++++++++----------------------------
 1 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/permission/PermissionServiceImpl.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/permission/PermissionServiceImpl.java
index a4deaf4..06ea1cb 100644
--- a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/permission/PermissionServiceImpl.java
+++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/service/permission/PermissionServiceImpl.java
@@ -172,34 +172,34 @@
 
     // ========== 角色-菜单的相关方法  ==========
 
-    @Override
-    @DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
-    @CacheEvict(value = RedisKeyConstants.MENU_ROLE_ID_LIST,
-            allEntries = true) // allEntries 清空所有缓存,主要一次更新涉及到的 menuIds 较多,反倒批量会更快
-    public void assignRoleAppMenu(Long roleId, Set<Long> menuIds) {
-        // 获得角色拥有应用菜单编号
-        MenuListReqVO reqVO = new MenuListReqVO();
-        List<MenuDO> appMenuList = menuService.getAppMenuList(reqVO);
-        Set<Long> appMenuIds = convertSet(appMenuList, MenuDO::getId);
-        Set<Long> dbMenuIds = convertSet(roleMenuMapper.selectListByRoleId(roleId), RoleMenuDO::getMenuId);
-        dbMenuIds.retainAll(appMenuIds);
-        // 计算新增和删除的菜单编号
-        Set<Long> menuIdList = CollUtil.emptyIfNull(menuIds);
-        Collection<Long> createMenuIds = CollUtil.subtract(menuIdList, dbMenuIds);
-        Collection<Long> deleteMenuIds = CollUtil.subtract(dbMenuIds, menuIdList);
-        // 执行新增和删除。对于已经授权的菜单,不用做任何处理
-        if (CollUtil.isNotEmpty(createMenuIds)) {
-            roleMenuMapper.insertBatch(CollectionUtils.convertList(createMenuIds, menuId -> {
-                RoleMenuDO entity = new RoleMenuDO();
-                entity.setRoleId(roleId);
-                entity.setMenuId(menuId);
-                return entity;
-            }));
-        }
-        if (CollUtil.isNotEmpty(deleteMenuIds)) {
-            roleMenuMapper.deleteListByRoleIdAndMenuIds(roleId, deleteMenuIds);
-        }
-    }
+//    @Override
+//    @DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
+//    @CacheEvict(value = RedisKeyConstants.MENU_ROLE_ID_LIST,
+//            allEntries = true) // allEntries 清空所有缓存,主要一次更新涉及到的 menuIds 较多,反倒批量会更快
+//    public void assignRoleAppMenu(Long roleId, Set<Long> menuIds) {
+//        // 获得角色拥有应用菜单编号
+//        MenuListReqVO reqVO = new MenuListReqVO();
+//        List<MenuDO> appMenuList = menuService.getAppMenuList(reqVO);
+//        Set<Long> appMenuIds = convertSet(appMenuList, MenuDO::getId);
+//        Set<Long> dbMenuIds = convertSet(roleMenuMapper.selectListByRoleId(roleId), RoleMenuDO::getMenuId);
+//        dbMenuIds.retainAll(appMenuIds);
+//        // 计算新增和删除的菜单编号
+//        Set<Long> menuIdList = CollUtil.emptyIfNull(menuIds);
+//        Collection<Long> createMenuIds = CollUtil.subtract(menuIdList, dbMenuIds);
+//        Collection<Long> deleteMenuIds = CollUtil.subtract(dbMenuIds, menuIdList);
+//        // 执行新增和删除。对于已经授权的菜单,不用做任何处理
+//        if (CollUtil.isNotEmpty(createMenuIds)) {
+//            roleMenuMapper.insertBatch(CollectionUtils.convertList(createMenuIds, menuId -> {
+//                RoleMenuDO entity = new RoleMenuDO();
+//                entity.setRoleId(roleId);
+//                entity.setMenuId(menuId);
+//                return entity;
+//            }));
+//        }
+//        if (CollUtil.isNotEmpty(deleteMenuIds)) {
+//            roleMenuMapper.deleteListByRoleIdAndMenuIds(roleId, deleteMenuIds);
+//        }
+//    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -227,6 +227,10 @@
         if (CollUtil.isEmpty(roleIds)) {
             return Collections.emptySet();
         }
+        // 如果是管理员的情况下,获取全部菜单编号
+        if (roleService.hasAnySuperAdmin(roleIds)) {
+            return convertSet(menuService.getMenuList(), MenuDO::getId);
+        }
         return convertSet(roleMenuMapper.selectListByRoleId(roleIds), RoleMenuDO::getMenuId);
     }
 

--
Gitblit v1.9.3