解决超管菜单获取的bug

This commit is contained in:
jishenghua
2025-04-02 14:59:17 +08:00
parent c1de4c53e2
commit 6a2f2d1425
2 changed files with 24 additions and 25 deletions

View File

@@ -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);

View File

@@ -242,8 +242,6 @@ public class FunctionService {
Long roleId = 0L; Long roleId = 0L;
String fc = ""; String fc = "";
User userInfo = userService.getCurrentUser(); User userInfo = userService.getCurrentUser();
//只返回非租户的map如果是租户就返回空数组
if(!userInfo.getId().equals(userInfo.getTenantId())) {
//获取当前用户所有的角色id //获取当前用户所有的角色id
List<UserBusiness> roleList = userBusinessService.getBasicData(userInfo.getTenantId().toString(), "UserRole"); List<UserBusiness> roleList = userBusinessService.getBasicData(userInfo.getTenantId().toString(), "UserRole");
if(roleList!=null && roleList.size()>0){ if(roleList!=null && roleList.size()>0){
@@ -263,7 +261,6 @@ public class FunctionService {
fc = fc.replace("][",","); fc = fc.replace("][",",");
funIdList = StringUtil.strToLongList(fc); funIdList = StringUtil.strToLongList(fc);
} }
}
return funIdList; return funIdList;
} }