|  |  | @ -5,6 +5,7 @@ import com.epmet.bean.OpeScopeFilterResultBean; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.AppClientConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.EpmetErrorCode; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.security.dto.GovTokenDto; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.security.user.LoginUserUtil; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.CpUserDetailRedis; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
	
		
			
				
					|  |  | @ -89,15 +90,15 @@ public class AccessServiceImpl implements AccessService { | 
			
		
	
		
			
				
					|  |  |  |         if (userDetails == null) { | 
			
		
	
		
			
				
					|  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         Set<String> roleIdList = userDetails.getRoleIdList(); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(roleIdList)) { | 
			
		
	
		
			
				
					|  |  |  |         List<GovTokenDto.Role> roleList = userDetails.getRoleList(); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(roleList)) { | 
			
		
	
		
			
				
					|  |  |  |             return false; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         final Set<String> operationKeys = new HashSet<>(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         roleIdList.stream().forEach(roleId -> { | 
			
		
	
		
			
				
					|  |  |  |             List<RoleOpeScopeResultDTO> opeAndScopes = listAllRoleOperationScopesByRoleId(roleId); | 
			
		
	
		
			
				
					|  |  |  |         roleList.stream().forEach(role -> { | 
			
		
	
		
			
				
					|  |  |  |             List<RoleOpeScopeResultDTO> opeAndScopes = listAllRoleOperationScopesByRoleId(role.getId()); | 
			
		
	
		
			
				
					|  |  |  |             operationKeys.addAll(opeAndScopes.stream().map(opeAndScope -> opeAndScope.getOperationKey()).collect(Collectors.toSet())); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -118,12 +119,12 @@ public class AccessServiceImpl implements AccessService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         StringBuilder sb = new StringBuilder(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(userDetails.getRoleIdList())) { | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(userDetails.getRoleList())) { | 
			
		
	
		
			
				
					|  |  |  |             //logger.warn("用户{}没有配置任何角色,无法执行{}操作", form.getUserId(), form.getOperationKey());
 | 
			
		
	
		
			
				
					|  |  |  |             throw new RenException(String.format("用户%s没有配置任何角色,无法执行%s操作", form.getUserId(), form.getOperationKey())); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         OpeScopeFilterResultBean effectiveOpeScopes = getEffectiveOpeScopes(userDetails.getRoleIdList(), form.getOperationKey()); | 
			
		
	
		
			
				
					|  |  |  |         OpeScopeFilterResultBean effectiveOpeScopes = getEffectiveOpeScopes(userDetails.getRoleList(), form.getOperationKey()); | 
			
		
	
		
			
				
					|  |  |  |         if (effectiveOpeScopes.isAllScopes()) { | 
			
		
	
		
			
				
					|  |  |  |             return sb.toString(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  | @ -235,12 +236,12 @@ public class AccessServiceImpl implements AccessService { | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * 计算有效操作范围 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     public OpeScopeFilterResultBean getEffectiveOpeScopes(Set<String> roleIds, String reqiurePermission) { | 
			
		
	
		
			
				
					|  |  |  |     public OpeScopeFilterResultBean getEffectiveOpeScopes(List<GovTokenDto.Role> roles, String reqiurePermission) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         // 根据角色列表查询操作范围列表
 | 
			
		
	
		
			
				
					|  |  |  |         Set<RoleOpeScopeResultDTO> opeAndScopesOfThisOperation = new HashSet<>(); | 
			
		
	
		
			
				
					|  |  |  |         roleIds.forEach(roleId -> { | 
			
		
	
		
			
				
					|  |  |  |             List<RoleOpeScopeResultDTO> opes = listAllRoleOperationScopesByRoleId(roleId); | 
			
		
	
		
			
				
					|  |  |  |         roles.forEach(role -> { | 
			
		
	
		
			
				
					|  |  |  |             List<RoleOpeScopeResultDTO> opes = listAllRoleOperationScopesByRoleId(role.getId()); | 
			
		
	
		
			
				
					|  |  |  |             if (!CollectionUtils.isEmpty(opes)) { | 
			
		
	
		
			
				
					|  |  |  |                 opes.forEach(ope -> { | 
			
		
	
		
			
				
					|  |  |  |                     if (reqiurePermission.equals(ope.getOperationKey())) { | 
			
		
	
	
		
			
				
					|  |  | @ -441,7 +442,7 @@ public class AccessServiceImpl implements AccessService { | 
			
		
	
		
			
				
					|  |  |  |         // 获取机关单位中的角色
 | 
			
		
	
		
			
				
					|  |  |  |         // 目前一个人只在一个单位下,所以不动态查询,如果后面需要一个人在多个单位,再改这里
 | 
			
		
	
		
			
				
					|  |  |  |         //List<GovStaffRoleDTO> roleDTOS = queryGovStaffRoles(staffId, belongAgency.getId());
 | 
			
		
	
		
			
				
					|  |  |  |         Set<String> roleIdList = userDetails.getRoleIdList(); | 
			
		
	
		
			
				
					|  |  |  |         List<GovTokenDto.Role> roleList = userDetails.getRoleList(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         // 当前组织和所属组织的orgId路径,以及他们的上下级关系
 | 
			
		
	
		
			
				
					|  |  |  |         String belongOrgIdPath = getOrgIdPath(belongAgency); | 
			
		
	
	
		
			
				
					|  |  | @ -450,9 +451,9 @@ public class AccessServiceImpl implements AccessService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         Set<String> filtedOps = new HashSet<>(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(roleIdList)) { | 
			
		
	
		
			
				
					|  |  |  |             roleIdList.forEach(roleId -> { | 
			
		
	
		
			
				
					|  |  |  |                 List<RoleOpeScopeResultDTO> opeAndScopeDTO = listAllRoleOperationScopesByRoleId(roleId); | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(roleList)) { | 
			
		
	
		
			
				
					|  |  |  |             roleList.forEach(role -> { | 
			
		
	
		
			
				
					|  |  |  |                 List<RoleOpeScopeResultDTO> opeAndScopeDTO = listAllRoleOperationScopesByRoleId(role.getId()); | 
			
		
	
		
			
				
					|  |  |  |                 filtedOps.addAll(filterOpesByScope(currOrgRelation, opeAndScopeDTO)); | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  | 
 |