| | |
| | | import org.apache.commons.lang.ObjectUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | |
| | | /** |
| | | /**current |
| | | * 两层循环实现建树 |
| | | * |
| | | * @param sysMenus |
| | |
| | | |
| | | @ApiOperation(value = "根据roleCodes获取对应的权限") |
| | | @SuppressWarnings("unchecked") |
| | | @Cacheable(value = "menu", key ="#roleCodes") |
| | | // @Cacheable(value = "menu", key ="#roleCodes") |
| | | @GetMapping("/{roleCodes}") |
| | | public List<SysMenu> findMenuByRoles(@PathVariable String roleCodes) { |
| | | List<SysMenu> result = null; |
| | |
| | | if (CollectionUtil.isEmpty(roles)) { |
| | | return ResultBody.ok().data(Collections.emptyList()); |
| | | } |
| | | List<SysMenu> menus = menuService.findByRoleCodes(roles.parallelStream().map(SysRole::getCode).collect(Collectors.toSet()), CommonConstant.MENU); |
| | | Set<String> collect = roles.stream().map(e -> e.getCode()).collect(Collectors.toSet()); |
| | | List<SysMenu> menus = menuService.findByRoleCodes(collect, CommonConstant.MENU); |
| | | return ResultBody.ok().data(treeBuilder(menus)); |
| | | } |
| | | } |