|
|
@ -1,17 +1,12 @@ |
|
|
|
package com.bweb.controller; |
|
|
|
package com.bweb.controller; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
import com.hfkj.common.utils.HttpUtils; |
|
|
|
|
|
|
|
import com.hfkj.common.utils.HttpsUtils; |
|
|
|
|
|
|
|
import com.hfkj.common.utils.ResponseMsgUtil; |
|
|
|
import com.hfkj.common.utils.ResponseMsgUtil; |
|
|
|
import com.hfkj.entity.SecMenu; |
|
|
|
import com.hfkj.entity.SecMenu; |
|
|
|
import com.hfkj.entity.SecRoleMenuRel; |
|
|
|
import com.hfkj.entity.SecRoleMenuRel; |
|
|
|
import com.hfkj.model.MenuTreeModel; |
|
|
|
|
|
|
|
import com.hfkj.model.ResponseData; |
|
|
|
import com.hfkj.model.ResponseData; |
|
|
|
import com.hfkj.service.SecMenuService; |
|
|
|
import com.hfkj.service.SecMenuService; |
|
|
|
import com.hfkj.service.SecRoleMenuRelService; |
|
|
|
import com.hfkj.service.SecRoleMenuRelService; |
|
|
@ -26,7 +21,6 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.function.Function; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -174,39 +168,10 @@ public class SecMenuController { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
// 查询角色菜单权限
|
|
|
|
// 查询角色菜单权限
|
|
|
|
Map<Long, SecMenu> roleMenu = secMenuService.queryRoleMenu(roleId, SecMenuTypeEnum.type1).stream() |
|
|
|
List<SecRoleMenuRel> roleMenuList = secRoleMenuRelService.getRelListByRole(roleId); |
|
|
|
.collect(Collectors.toMap(SecMenu::getId, Function.identity())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 系统菜单叶节点
|
|
|
|
return ResponseMsgUtil.success(roleMenuList.stream().map(SecRoleMenuRel::getMenuId).collect(Collectors.toList()) |
|
|
|
List<String> menuLeafList = new ArrayList<>(); |
|
|
|
.stream().map(Object::toString).collect(Collectors.toList())); |
|
|
|
|
|
|
|
|
|
|
|
// 角色菜单叶节点
|
|
|
|
|
|
|
|
List<String> roleLeafList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取全部菜单
|
|
|
|
|
|
|
|
List<SecMenu> menuList = secMenuService.getAllList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取最顶层菜单
|
|
|
|
|
|
|
|
List<SecMenu> topLevelMenuList = menuList.stream() |
|
|
|
|
|
|
|
.filter(o -> o.getMenuPSid() == null) |
|
|
|
|
|
|
|
.sorted(Comparator.comparing(SecMenu::getMenuSort)) |
|
|
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 递归获取系统菜单叶子节点
|
|
|
|
|
|
|
|
for (SecMenu topLevelMenu : topLevelMenuList) { |
|
|
|
|
|
|
|
if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { |
|
|
|
|
|
|
|
recursionMenu(menuList, topLevelMenu.getId(), menuLeafList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 筛选角色菜单叶节点
|
|
|
|
|
|
|
|
for (String leaf : menuLeafList) { |
|
|
|
|
|
|
|
SecMenu menu = roleMenu.get(Long.parseLong(leaf)); |
|
|
|
|
|
|
|
if (menu != null) { |
|
|
|
|
|
|
|
roleLeafList.add(""+menu.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(roleLeafList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("error!",e); |
|
|
|
log.error("error!",e); |
|
|
@ -247,11 +212,11 @@ public class SecMenuController { |
|
|
|
|
|
|
|
|
|
|
|
for (SecMenu topLevelMenu : topLevelMenuList) { |
|
|
|
for (SecMenu topLevelMenu : topLevelMenuList) { |
|
|
|
if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { |
|
|
|
if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { |
|
|
|
map = new LinkedHashMap<>(); |
|
|
|
map = new HashMap<>(); |
|
|
|
map.put("key", ""+topLevelMenu.getId()); |
|
|
|
map.put("key", ""+topLevelMenu.getId()); |
|
|
|
map.put("title", topLevelMenu.getMenuName()); |
|
|
|
map.put("title", topLevelMenu.getMenuName()); |
|
|
|
// 获取下级菜单
|
|
|
|
// 获取下级菜单
|
|
|
|
map.put("children", recursionMenu(menuList, topLevelMenu.getId(), new ArrayList<>())); |
|
|
|
map.put("children", recursionMenu(menuList, topLevelMenu.getId())); |
|
|
|
mapList.add(map); |
|
|
|
mapList.add(map); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -270,7 +235,7 @@ public class SecMenuController { |
|
|
|
* @param parentMenuId 父级菜单id |
|
|
|
* @param parentMenuId 父级菜单id |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<Map<String,Object>> recursionMenu(List<SecMenu> dataSource, Long parentMenuId, List<String> leaf) { |
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
@ -280,13 +245,12 @@ public class SecMenuController { |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
for (SecMenu menu : collect) { |
|
|
|
for (SecMenu menu : collect) { |
|
|
|
if (menu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { |
|
|
|
if (menu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) { |
|
|
|
map = new LinkedHashMap<>(); |
|
|
|
map = new HashMap<>(); |
|
|
|
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 = recursionMenu(dataSource, menu.getId(), leaf); |
|
|
|
List<Map<String, Object>> recursioned = recursionMenu(dataSource, menu.getId()); |
|
|
|
if (recursioned.isEmpty()) { |
|
|
|
if (recursioned.isEmpty()) { |
|
|
|
leaf.add(""+menu.getId()); |
|
|
|
|
|
|
|
map.put("isLeaf", true); |
|
|
|
map.put("isLeaf", true); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
map.put("children", recursioned); |
|
|
|
map.put("children", recursioned); |
|
|
@ -297,5 +261,4 @@ public class SecMenuController { |
|
|
|
return mapList; |
|
|
|
return mapList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|