mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
【修复】获取菜单精简信息列表接口没有排除父 ID 非 0 的节点
This commit is contained in:
parent
6419aef36c
commit
1c7ba5c0d6
@ -109,9 +109,10 @@ public class AuthController {
|
||||
// 1.3 获得菜单列表
|
||||
Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId));
|
||||
List<MenuDO> 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));
|
||||
}
|
||||
|
@ -126,16 +126,18 @@ public class MenuServiceImpl implements MenuService {
|
||||
if(CollectionUtils.isEmpty(menuList)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<MenuDO> allMenuList = getMenuList();
|
||||
|
||||
// 根据parentId快速查找子节点
|
||||
Map<Long, List<MenuDO>> childrenMap = menuList.stream()
|
||||
Map<Long, List<MenuDO>> childrenMap = allMenuList.stream()
|
||||
.collect(Collectors.groupingBy(MenuDO::getParentId));
|
||||
|
||||
// 所有关闭的节点ID
|
||||
Set<Long> 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user