|
|
@ -170,44 +170,17 @@ public class SecMenuController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/queryAssignMenuTree",method = RequestMethod.GET) |
|
|
|
@RequestMapping(value="/queryRoleMenuArray",method = RequestMethod.GET) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "查询分配菜单树") |
|
|
|
@ApiOperation(value = "查询分配菜单树") |
|
|
|
public ResponseData queryAssignMenuTree(@RequestParam(value = "roleId" , required = true) Long roleId) { |
|
|
|
public ResponseData queryRoleMenuArray(@RequestParam(value = "roleId" , required = true) Long roleId) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
List<MenuTreeModel> treeModelList = new ArrayList<>(); |
|
|
|
// 查询角色菜单权限
|
|
|
|
MenuTreeModel menuTree; |
|
|
|
List<SecRoleMenuRel> roleMenuList = secRoleMenuRelService.getRelListByRole(roleId); |
|
|
|
|
|
|
|
|
|
|
|
// 获取系统菜单
|
|
|
|
return ResponseMsgUtil.success(roleMenuList.stream().map(SecRoleMenuRel::getMenuId).collect(Collectors.toList()) |
|
|
|
List<SecMenu> sysMenuList = secMenuService.getAllList(); |
|
|
|
.stream().map(Object::toString).collect(Collectors.toList())); |
|
|
|
Map<Long, SecRoleMenuRel> roleMenuRelMap = secRoleMenuRelService.getRelListByRole(roleId) |
|
|
|
|
|
|
|
.stream() |
|
|
|
|
|
|
|
.collect(Collectors.toMap(SecRoleMenuRel::getMenuId, Function.identity())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取系统顶级菜单
|
|
|
|
|
|
|
|
List<SecMenu> topLevelMenuList = sysMenuList.stream().filter(o -> o.getMenuPSid() == null) |
|
|
|
|
|
|
|
.sorted(Comparator.comparing(SecMenu::getMenuSort)) |
|
|
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (SecMenu topLevelMenu : topLevelMenuList) { |
|
|
|
|
|
|
|
menuTree = new MenuTreeModel(); |
|
|
|
|
|
|
|
menuTree.setId(topLevelMenu.getId()); |
|
|
|
|
|
|
|
menuTree.setMenuName(topLevelMenu.getMenuName()); |
|
|
|
|
|
|
|
menuTree.setMenuType(topLevelMenu.getMenuType()); |
|
|
|
|
|
|
|
menuTree.setMenuUrl(topLevelMenu.getMenuUrl()); |
|
|
|
|
|
|
|
menuTree.setMenuUrlImg(topLevelMenu.getMenuUrlImg()); |
|
|
|
|
|
|
|
menuTree.setMenuPSid(topLevelMenu.getMenuPSid()); |
|
|
|
|
|
|
|
menuTree.setMenuSort(topLevelMenu.getMenuSort()); |
|
|
|
|
|
|
|
menuTree.setMenuDesc(topLevelMenu.getMenuDesc()); |
|
|
|
|
|
|
|
// 递归子菜单
|
|
|
|
|
|
|
|
menuTree.setChildMenuList(recursionMenu(sysMenuList, roleMenuRelMap, topLevelMenu.getId())); |
|
|
|
|
|
|
|
// 获取角色菜单
|
|
|
|
|
|
|
|
menuTree.setAuthority(roleMenuRelMap.get(topLevelMenu.getId()) != null ? true : false); |
|
|
|
|
|
|
|
treeModelList.add(menuTree); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(treeModelList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("error!",e); |
|
|
|
log.error("error!",e); |
|
|
@ -229,10 +202,10 @@ public class SecMenuController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/queryRoleMenuTreeCustomized",method = RequestMethod.POST) |
|
|
|
@RequestMapping(value="/queryMenuTree",method = RequestMethod.POST) |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
@ApiOperation(value = "查询角色菜单树") |
|
|
|
@ApiOperation(value = "查询角色菜单树") |
|
|
|
public ResponseData queryRoleMenuTreeCustomized(@RequestParam(value = "roleId" , required = false) Long roleId) { |
|
|
|
public ResponseData queryMenuTree() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
List<Map<String,Object>> mapList = new ArrayList<>(); |
|
|
|
List<Map<String,Object>> mapList = new ArrayList<>(); |
|
|
|
Map<String,Object> map; |
|
|
|
Map<String,Object> map; |
|
|
@ -252,7 +225,7 @@ public class SecMenuController { |
|
|
|
map.put("key", ""+topLevelMenu.getId()); |
|
|
|
map.put("key", ""+topLevelMenu.getId()); |
|
|
|
map.put("title", topLevelMenu.getMenuName()); |
|
|
|
map.put("title", topLevelMenu.getMenuName()); |
|
|
|
// 获取下级菜单
|
|
|
|
// 获取下级菜单
|
|
|
|
map.put("children", recursionMenu2(menuList, topLevelMenu.getId())); |
|
|
|
map.put("children", recursionMenu(menuList, topLevelMenu.getId())); |
|
|
|
mapList.add(map); |
|
|
|
mapList.add(map); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -271,7 +244,7 @@ public class SecMenuController { |
|
|
|
* @param parentMenuId 父级菜单id |
|
|
|
* @param parentMenuId 父级菜单id |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<Map<String,Object>> recursionMenu2(List<SecMenu> dataSource, Long parentMenuId) { |
|
|
|
public List<Map<String,Object>> recursionMenu(List<SecMenu> dataSource, Long parentMenuId) { |
|
|
|
List<Map<String,Object>> mapList = new ArrayList<>(); |
|
|
|
List<Map<String,Object>> mapList = new ArrayList<>(); |
|
|
|
Map<String,Object> map; |
|
|
|
Map<String,Object> map; |
|
|
|
|
|
|
|
|
|
|
@ -285,7 +258,7 @@ public class SecMenuController { |
|
|
|
map.put("key", ""+menu.getId()); |
|
|
|
map.put("key", ""+menu.getId()); |
|
|
|
map.put("title", menu.getMenuName()); |
|
|
|
map.put("title", menu.getMenuName()); |
|
|
|
// 获取下级菜单
|
|
|
|
// 获取下级菜单
|
|
|
|
List<Map<String, Object>> recursioned = recursionMenu2(dataSource, menu.getId()); |
|
|
|
List<Map<String, Object>> recursioned = recursionMenu(dataSource, menu.getId()); |
|
|
|
if (recursioned.isEmpty()) { |
|
|
|
if (recursioned.isEmpty()) { |
|
|
|
map.put("isLeaf", true); |
|
|
|
map.put("isLeaf", true); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -297,36 +270,4 @@ public class SecMenuController { |
|
|
|
return mapList; |
|
|
|
return mapList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 递归菜单 |
|
|
|
|
|
|
|
* @param sysMenu 系统菜单 |
|
|
|
|
|
|
|
* @param roleMenuRel 角色菜单 |
|
|
|
|
|
|
|
* @param parentMenuId 父类菜单id |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public List<MenuTreeModel> recursionMenu(List<SecMenu> sysMenu, Map<Long, SecRoleMenuRel> roleMenuRel, Long parentMenuId) { |
|
|
|
|
|
|
|
List<MenuTreeModel> treeModelList = new ArrayList<>(); |
|
|
|
|
|
|
|
MenuTreeModel menuTree; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SecMenu> collect = sysMenu.stream() |
|
|
|
|
|
|
|
.filter(o -> o.getMenuPSid() != null && o.getMenuPSid().equals(parentMenuId)) |
|
|
|
|
|
|
|
.sorted(Comparator.comparing(SecMenu::getMenuSort)) |
|
|
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
for (SecMenu menu : collect) { |
|
|
|
|
|
|
|
menuTree = new MenuTreeModel(); |
|
|
|
|
|
|
|
menuTree.setId(menu.getId()); |
|
|
|
|
|
|
|
menuTree.setMenuName(menu.getMenuName()); |
|
|
|
|
|
|
|
menuTree.setMenuType(menu.getMenuType()); |
|
|
|
|
|
|
|
menuTree.setMenuUrl(menu.getMenuUrl()); |
|
|
|
|
|
|
|
menuTree.setMenuUrlImg(menu.getMenuUrlImg()); |
|
|
|
|
|
|
|
menuTree.setMenuPSid(menu.getMenuPSid()); |
|
|
|
|
|
|
|
menuTree.setMenuSort(menu.getMenuSort()); |
|
|
|
|
|
|
|
menuTree.setMenuDesc(menu.getMenuDesc()); |
|
|
|
|
|
|
|
// 获取角色菜单
|
|
|
|
|
|
|
|
menuTree.setAuthority(roleMenuRel.get(menuTree.getId()) != null ? true : false); |
|
|
|
|
|
|
|
menuTree.setChildMenuList(recursionMenu(sysMenu, roleMenuRel, menu.getId())); |
|
|
|
|
|
|
|
treeModelList.add(menuTree); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return treeModelList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|