|
@@ -3,6 +3,7 @@ package com.jiayue.ssi.controller;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import com.jiayue.ssi.annotation.OperateLog;
|
|
@@ -317,4 +318,40 @@ public class SysMenuController {
|
|
|
throw new CustomException("获取对应角色菜单列表树异常", e);
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 加载对应角色菜单列表树
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/roleMenuTreeselectForUser")
|
|
|
+ @OperateLog(title = "菜单管理", businessType = BusinessType.QUERY, auditType = AuditType.SYS,operdesc = "获取角色菜单列表")
|
|
|
+ @PreventReplay
|
|
|
+ public ResponseVO roleMenuTreeselectForUser(String roleId) throws CustomException {
|
|
|
+ try {
|
|
|
+ Long roleid;
|
|
|
+ if (StringUtils.isNotEmpty(roleId)) {
|
|
|
+ if (NumberUtil.isLong(roleId)){
|
|
|
+ roleid = Long.parseLong(roleId);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return ResponseVO.fail("角色id不是类型不对!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return ResponseVO.fail("角色id不能为空!");
|
|
|
+ }
|
|
|
+ SysRole sysRole = sysRoleService.selectRoleById(roleid);
|
|
|
+ if (sysRole==null){
|
|
|
+ return ResponseVO.fail("找不到角色不能查找角色关联树!");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysMenu> menus = sysMenuService.selectMenuList(SecurityContextUtil.getSysUser().getId());
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("checkedKeys", sysMenuService.selectMenuListByRoleId(roleid));
|
|
|
+ // 将获取的菜单过滤出按钮级别
|
|
|
+ List<SysMenu> notMenuTypeList = menus.stream().filter(menu -> !menu.getMenuType().equals("F")).collect(Collectors.toList());
|
|
|
+ map.put("menus", sysMenuService.buildMenuTreeSelect(notMenuTypeList,sysRole.getRoleKey()));
|
|
|
+ return ResponseVO.success(map);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new CustomException("获取对应角色菜单列表树异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|