use of com.besscroft.aurora.mall.common.model.RoleResourceRelation in project aurora-mall by besscroft.
the class ResourceServiceImpl method initRoleResourceMap.
@Override
public Map<String, List<String>> initRoleResourceMap() {
Map<String, List<String>> RoleResourceMap = new TreeMap<>();
List<AuthResource> authResourceList = this.baseMapper.selectAll();
List<AuthRole> authRoleList = authRoleMapper.selectAll();
List<RoleResourceRelation> roleResourceRelationList = roleResourceRelationMapper.selectAll();
for (AuthResource resource : authResourceList) {
Set<Long> roleIds = roleResourceRelationList.stream().filter(item -> item.getResourceId().equals(resource.getId())).map(RoleResourceRelation::getRoleId).collect(Collectors.toSet());
List<String> roleNames = authRoleList.stream().filter(item -> roleIds.contains(item.getId())).map(item -> AuthConstants.AUTHORITY_PREFIX + item.getId() + "_" + item.getName()).collect(Collectors.toList());
// key为访问路径/资源路径,value为角色
RoleResourceMap.put("/" + applicationName + resource.getUrl(), roleNames);
}
redisTemplate.delete(AuthConstants.PERMISSION_RULES_KEY);
redisTemplate.opsForHash().putAll(AuthConstants.PERMISSION_RULES_KEY, RoleResourceMap);
return RoleResourceMap;
}
Aggregations