| 
						
						
							
								
							
						
						
					 | 
					@ -29,6 +29,7 @@ import com.epmet.dao.RoleOperationDefaultDao; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dao.RoleScopeDao; | 
					 | 
					 | 
					import com.epmet.dao.RoleScopeDao; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.RoleOperationDTO; | 
					 | 
					 | 
					import com.epmet.dto.RoleOperationDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.form.InitDefaultOperationsFormDTO; | 
					 | 
					 | 
					import com.epmet.dto.form.InitDefaultOperationsFormDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.dto.result.OperationScopeDefaultResultDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.result.RoleOperationDefaultResultDTO; | 
					 | 
					 | 
					import com.epmet.dto.result.RoleOperationDefaultResultDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.result.RoleOperationResultDTO; | 
					 | 
					 | 
					import com.epmet.dto.result.RoleOperationResultDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.entity.OperationScopeDefaultEntity; | 
					 | 
					 | 
					import com.epmet.entity.OperationScopeDefaultEntity; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -124,9 +125,6 @@ public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Transactional | 
					 | 
					 | 
					    @Transactional | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public void initDefaultOperationsForRoles(List<InitDefaultOperationsFormDTO.InitDefaultOpesRoleDTO> roles) { | 
					 | 
					 | 
					    public void initDefaultOperationsForRoles(List<InitDefaultOperationsFormDTO.InitDefaultOpesRoleDTO> roles) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        List<OperationScopeDefaultEntity> validScopeDefaults = operationScopeDefaultDao.listAllValid(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        HashMap<String, Set<String>> opeScopeMap = convertScopeDefaultEntity2Map(validScopeDefaults); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        for (InitDefaultOperationsFormDTO.InitDefaultOpesRoleDTO role : roles) { | 
					 | 
					 | 
					        for (InitDefaultOperationsFormDTO.InitDefaultOpesRoleDTO role : roles) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String roleId = role.getRoleId(); | 
					 | 
					 | 
					            String roleId = role.getRoleId(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            String roleKey = role.getRoleKey(); | 
					 | 
					 | 
					            String roleKey = role.getRoleKey(); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -134,7 +132,7 @@ public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            if (!CollectionUtils.isEmpty(defaultOperations)) { | 
					 | 
					 | 
					            if (!CollectionUtils.isEmpty(defaultOperations)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                // 有的角色并没有配置默认的操作权限,应该忽略
 | 
					 | 
					 | 
					                // 有的角色并没有配置默认的操作权限,应该忽略
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                initDefaultOperationsForRole(roleId, defaultOperations); | 
					 | 
					 | 
					                initDefaultOperationsForRole(roleId, defaultOperations); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                initDefaultOperationScopesForRole(roleId, defaultOperations, opeScopeMap); | 
					 | 
					 | 
					                initDefaultOperationScopesForRole(roleId, roleKey, defaultOperations); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -159,8 +157,10 @@ public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @param roleId 角色ID | 
					 | 
					 | 
					     * @param roleId 角色ID | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @param operations 该角色可以做的操作列表 | 
					 | 
					 | 
					     * @param operations 该角色可以做的操作列表 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     */ | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    public void initDefaultOperationScopesForRole(String roleId, List<RoleOperationDefaultResultDTO> operations, HashMap<String, Set<String>> opeScopeMap) { | 
					 | 
					 | 
					    public void initDefaultOperationScopesForRole(String roleId, String roleKey, List<RoleOperationDefaultResultDTO> operations) { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        HashMap<String, Set<String>> opeScopeMap = listDefaultOpeScopesMap(roleKey); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        for (RoleOperationDefaultResultDTO operation : operations) { | 
					 | 
					 | 
					        for (RoleOperationDefaultResultDTO operation : operations) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            // 该角色,该操作的操作范围列表
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Set<String> scopeKeys4ThisOpe = opeScopeMap.get(operation.getOperationKey()); | 
					 | 
					 | 
					            Set<String> scopeKeys4ThisOpe = opeScopeMap.get(operation.getOperationKey()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            if (!CollectionUtils.isEmpty(scopeKeys4ThisOpe)) { | 
					 | 
					 | 
					            if (!CollectionUtils.isEmpty(scopeKeys4ThisOpe)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                for (String scopeKey : scopeKeys4ThisOpe) { | 
					 | 
					 | 
					                for (String scopeKey : scopeKeys4ThisOpe) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -174,6 +174,11 @@ public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    private HashMap<String, Set<String>> listDefaultOpeScopesMap(String roleKey) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        List<OperationScopeDefaultResultDTO> defaultScopes = operationScopeDefaultDao.listDefaultOpeScopes(roleKey); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        return convertScopeDefaultDto2Map(defaultScopes); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    /** | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * 将默认范围entity转换为map | 
					 | 
					 | 
					     * 将默认范围entity转换为map | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @param entities | 
					 | 
					 | 
					     * @param entities | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -192,4 +197,22 @@ public class RoleOperationServiceImpl extends BaseServiceImpl<RoleOperationDao, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return map; | 
					 | 
					 | 
					        return map; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * 将默认范围dto转换为map | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @param dtos | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @return | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    private HashMap<String, Set<String>> convertScopeDefaultDto2Map(List<OperationScopeDefaultResultDTO> dtos) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        HashMap<String, Set<String>> map = new HashMap<>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        for (OperationScopeDefaultResultDTO dto : dtos) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            Set<String> scopes = map.get(dto.getOperationKey()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (scopes == null) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                scopes = new HashSet<>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                map.put(dto.getOperationKey(), scopes); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            scopes.add(dto.getScopeKey()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        return map; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} |