解决超管菜单获取的bug
This commit is contained in:
		
							parent
							
								
									c1de4c53e2
								
							
						
					
					
						commit
						6a2f2d1425
					
				| @ -170,11 +170,13 @@ public class FunctionController extends BaseController { | ||||
|             if(list.size()>0) { | ||||
|                 approvalFlag = list.get(0).getMultiLevelApprovalFlag(); | ||||
|             } | ||||
| 
 | ||||
|             List<Function> dataList = functionService.getRoleFunction(pNumber); | ||||
|             if (dataList.size() != 0) { | ||||
|                 User userInfo = userService.getCurrentUser(); | ||||
|                 //获取当前用户所属的租户所拥有的功能id的map | ||||
|                 Map<Long, Long> funIdMap = functionService.getCurrentTenantFunIdMap(); | ||||
|                 dataArray = getMenuByFunction(dataList, fc, approvalFlag, funIdMap); | ||||
|                 dataArray = getMenuByFunction(dataList, fc, approvalFlag, funIdMap, userInfo); | ||||
|                 //增加首页菜单项 | ||||
|                 JSONObject homeItem = new JSONObject(); | ||||
|                 homeItem.put("id", 0); | ||||
| @ -190,11 +192,11 @@ public class FunctionController extends BaseController { | ||||
|         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(); | ||||
|         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())) { | ||||
|                     continue; | ||||
| @ -207,7 +209,7 @@ public class FunctionController extends BaseController { | ||||
|                 item.put("url", function.getUrl()); | ||||
|                 item.put("component", function.getComponent()); | ||||
|                 if (newList.size()>0) { | ||||
|                     JSONArray childrenArr = getMenuByFunction(newList, fc, approvalFlag, funIdMap); | ||||
|                     JSONArray childrenArr = getMenuByFunction(newList, fc, approvalFlag, funIdMap, userInfo); | ||||
|                     if(childrenArr.size()>0) { | ||||
|                         item.put("children", childrenArr); | ||||
|                         dataArray.add(item); | ||||
|  | ||||
| @ -242,28 +242,25 @@ public class FunctionService { | ||||
|         Long roleId = 0L; | ||||
|         String fc = ""; | ||||
|         User userInfo = userService.getCurrentUser(); | ||||
|         //只返回非租户的map,如果是租户就返回空数组 | ||||
|         if(!userInfo.getId().equals(userInfo.getTenantId())) { | ||||
|             //获取当前用户所有的角色id | ||||
|             List<UserBusiness> roleList = userBusinessService.getBasicData(userInfo.getTenantId().toString(), "UserRole"); | ||||
|             if(roleList!=null && roleList.size()>0){ | ||||
|                 String value = roleList.get(0).getValue(); | ||||
|                 if(StringUtil.isNotEmpty(value)){ | ||||
|                     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); | ||||
|         //获取当前用户所有的角色id | ||||
|         List<UserBusiness> roleList = userBusinessService.getBasicData(userInfo.getTenantId().toString(), "UserRole"); | ||||
|         if(roleList!=null && roleList.size()>0){ | ||||
|             String value = roleList.get(0).getValue(); | ||||
|             if(StringUtil.isNotEmpty(value)){ | ||||
|                 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); | ||||
|         } | ||||
|         return funIdList; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 jishenghua
						jishenghua