解决超管菜单获取的bug
This commit is contained in:
parent
c1de4c53e2
commit
6a2f2d1425
@ -170,11 +170,13 @@ public class FunctionController extends BaseController {
|
|||||||
if(list.size()>0) {
|
if(list.size()>0) {
|
||||||
approvalFlag = list.get(0).getMultiLevelApprovalFlag();
|
approvalFlag = list.get(0).getMultiLevelApprovalFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Function> dataList = functionService.getRoleFunction(pNumber);
|
List<Function> dataList = functionService.getRoleFunction(pNumber);
|
||||||
if (dataList.size() != 0) {
|
if (dataList.size() != 0) {
|
||||||
|
User userInfo = userService.getCurrentUser();
|
||||||
//获取当前用户所属的租户所拥有的功能id的map
|
//获取当前用户所属的租户所拥有的功能id的map
|
||||||
Map<Long, Long> funIdMap = functionService.getCurrentTenantFunIdMap();
|
Map<Long, Long> funIdMap = functionService.getCurrentTenantFunIdMap();
|
||||||
dataArray = getMenuByFunction(dataList, fc, approvalFlag, funIdMap);
|
dataArray = getMenuByFunction(dataList, fc, approvalFlag, funIdMap, userInfo);
|
||||||
//增加首页菜单项
|
//增加首页菜单项
|
||||||
JSONObject homeItem = new JSONObject();
|
JSONObject homeItem = new JSONObject();
|
||||||
homeItem.put("id", 0);
|
homeItem.put("id", 0);
|
||||||
@ -190,11 +192,11 @@ public class FunctionController extends BaseController {
|
|||||||
return dataArray;
|
return dataArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONArray getMenuByFunction(List<Function> dataList, String fc, String approvalFlag, Map<Long, Long> funIdMap) throws Exception {
|
public JSONArray getMenuByFunction(List<Function> dataList, String fc, String approvalFlag, Map<Long, Long> funIdMap, User userInfo) throws Exception {
|
||||||
JSONArray dataArray = new JSONArray();
|
JSONArray dataArray = new JSONArray();
|
||||||
for (Function function : dataList) {
|
for (Function function : dataList) {
|
||||||
//如果funIdMap有值(说明不是租户)需要校验,防止分配下级用户的功能权限,大于租户的权限
|
//如果不是超管也不是租户就需要校验,防止分配下级用户的功能权限,大于租户的权限
|
||||||
if(funIdMap == null || funIdMap.get(function.getId())!=null) {
|
if("admin".equals(userInfo.getLoginName()) || userInfo.getId().equals(userInfo.getTenantId()) || funIdMap.get(function.getId())!=null) {
|
||||||
//如果关闭多级审核,遇到任务审核菜单直接跳过
|
//如果关闭多级审核,遇到任务审核菜单直接跳过
|
||||||
if("0".equals(approvalFlag) && "/workflow".equals(function.getUrl())) {
|
if("0".equals(approvalFlag) && "/workflow".equals(function.getUrl())) {
|
||||||
continue;
|
continue;
|
||||||
@ -207,7 +209,7 @@ public class FunctionController extends BaseController {
|
|||||||
item.put("url", function.getUrl());
|
item.put("url", function.getUrl());
|
||||||
item.put("component", function.getComponent());
|
item.put("component", function.getComponent());
|
||||||
if (newList.size()>0) {
|
if (newList.size()>0) {
|
||||||
JSONArray childrenArr = getMenuByFunction(newList, fc, approvalFlag, funIdMap);
|
JSONArray childrenArr = getMenuByFunction(newList, fc, approvalFlag, funIdMap, userInfo);
|
||||||
if(childrenArr.size()>0) {
|
if(childrenArr.size()>0) {
|
||||||
item.put("children", childrenArr);
|
item.put("children", childrenArr);
|
||||||
dataArray.add(item);
|
dataArray.add(item);
|
||||||
|
|||||||
@ -242,28 +242,25 @@ public class FunctionService {
|
|||||||
Long roleId = 0L;
|
Long roleId = 0L;
|
||||||
String fc = "";
|
String fc = "";
|
||||||
User userInfo = userService.getCurrentUser();
|
User userInfo = userService.getCurrentUser();
|
||||||
//只返回非租户的map,如果是租户就返回空数组
|
//获取当前用户所有的角色id
|
||||||
if(!userInfo.getId().equals(userInfo.getTenantId())) {
|
List<UserBusiness> roleList = userBusinessService.getBasicData(userInfo.getTenantId().toString(), "UserRole");
|
||||||
//获取当前用户所有的角色id
|
if(roleList!=null && roleList.size()>0){
|
||||||
List<UserBusiness> roleList = userBusinessService.getBasicData(userInfo.getTenantId().toString(), "UserRole");
|
String value = roleList.get(0).getValue();
|
||||||
if(roleList!=null && roleList.size()>0){
|
if(StringUtil.isNotEmpty(value)){
|
||||||
String value = roleList.get(0).getValue();
|
String roleIdStr = value.replace("[", "").replace("]", "");
|
||||||
if(StringUtil.isNotEmpty(value)){
|
roleId = Long.parseLong(roleIdStr);
|
||||||
String roleIdStr = value.replace("[", "").replace("]", "");
|
|
||||||
roleId = Long.parseLong(roleIdStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//当前用户所拥有的功能列表,格式如:[1][2][5]
|
|
||||||
List<UserBusiness> funList = userBusinessService.getBasicData(roleId.toString(), "RoleFunctions");
|
|
||||||
if(funList!=null && funList.size()>0){
|
|
||||||
fc = funList.get(0).getValue();
|
|
||||||
}
|
|
||||||
if(StringUtil.isNotEmpty(fc)) {
|
|
||||||
fc = fc.substring(1, fc.length() - 1);
|
|
||||||
fc = fc.replace("][",",");
|
|
||||||
funIdList = StringUtil.strToLongList(fc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//当前用户所拥有的功能列表,格式如:[1][2][5]
|
||||||
|
List<UserBusiness> funList = userBusinessService.getBasicData(roleId.toString(), "RoleFunctions");
|
||||||
|
if(funList!=null && funList.size()>0){
|
||||||
|
fc = funList.get(0).getValue();
|
||||||
|
}
|
||||||
|
if(StringUtil.isNotEmpty(fc)) {
|
||||||
|
fc = fc.substring(1, fc.length() - 1);
|
||||||
|
fc = fc.replace("][",",");
|
||||||
|
funIdList = StringUtil.strToLongList(fc);
|
||||||
|
}
|
||||||
return funIdList;
|
return funIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user