diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java index 20e9e9d6b9..6ebaba2123 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java @@ -109,9 +109,10 @@ public class AuthController { // 1.3 获得菜单列表 Set menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId)); List menuList = menuService.getMenuList(menuIds); - // 过滤掉关闭的菜单及其子菜单 + // 过滤掉关闭的菜单 menuList = menuService.filterClosedMenus(menuList); + menuList.removeIf(menu -> !CommonStatusEnum.ENABLE.getStatus().equals(menu.getStatus())); // 移除禁用的菜单 // 2. 拼接结果返回 return success(AuthConvert.INSTANCE.convert(user, roles, menuList)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java index bba798f84d..104da073d0 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java @@ -126,16 +126,18 @@ public class MenuServiceImpl implements MenuService { if(CollectionUtils.isEmpty(menuList)){ return Collections.emptyList(); } + List allMenuList = getMenuList(); + // 根据parentId快速查找子节点 - Map> childrenMap = menuList.stream() + Map> childrenMap = allMenuList.stream() .collect(Collectors.groupingBy(MenuDO::getParentId)); // 所有关闭的节点ID Set closedNodeIds = new HashSet<>(); // 标记所有关闭的节点 - for (MenuDO menu : menuList) { - if (Objects.equals(menu.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { + for (MenuDO menu : allMenuList) { + if (!Objects.equals(menu.getStatus(), CommonStatusEnum.ENABLE.getStatus())) { markClosedNodes(menu.getId(), childrenMap, closedNodeIds); } }