| | |
| | | * 获取角色下的菜单 |
| | | */ |
| | | public List<Menu> listByRoleIds(List<Long> roleIdList) { |
| | | List<Long> menuIdList = roleMenuRelationService.list(Wrappers.lambdaQuery(RoleMenuRelation.class).in(RoleMenuRelation::getRoleId, roleIdList).select(RoleMenuRelation::getMenuId)) |
| | | List<Long> menuIdList = roleMenuRelationService.list(Wrappers.lambdaQuery(RoleMenuRelation.class) |
| | | .in(RoleMenuRelation::getRoleId, roleIdList).select(RoleMenuRelation::getMenuId)) |
| | | .stream().map(RoleMenuRelation::getMenuId).distinct().collect(Collectors.toList()); |
| | | if (CollectionUtil.isEmpty(menuIdList)) { |
| | | return null; |
| | |
| | | BeanUtils.copyProperties(param, menu); |
| | | return save(menu); |
| | | } |
| | | |
| | | // public Set<Menu> listMenuByRoles(Set<Role> roles) { |
| | | // List<Long> roleIds = roles.stream().map(Role::getId).collect(Collectors.toList()); |
| | | // Set<Menu> menus = menuDao.listMenuByRoleIds(roleIds); |
| | | // return menus; |
| | | // } |
| | | // |
| | | // /** |
| | | // * 把菜单转成树形结构 |
| | | // */ |
| | | // public List<MenuNode> buildTree(List<Menu> menuList) { |
| | | // return menuList.stream() |
| | | // .filter(menu -> menu.getPid().equals(0L)) |
| | | // .map(menu -> covertMenuNode(menu, menuList)).collect(Collectors.toList()); |
| | | // } |
| | | |
| | | private MenuNode covertMenuNode(Menu menu, List<Menu> menuList) { |
| | | MenuNode node = new MenuNode(); |