feat:(2227-roleGroup):班组角色组权限查询

This commit is contained in:
zhansihu 2024-04-16 18:42:59 +08:00
parent c62bcac8d9
commit 2fef653f9f
2 changed files with 19 additions and 6 deletions

View File

@ -96,6 +96,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@ -894,10 +895,11 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
if (CollectionUtils.isEmpty(categoryCodes)) {
return new ArrayList<>();
}
List<SaasRoleCategoryVO> result = new ArrayList<>();
//category code转code 查询对应code及子级
List<SaasRoleGroup> saasRoleGroups = saasRoleGroupService.listByCodes(categoryCodes, 3);
//category code转code 查询对应code及子级
List<SaasRoleGroup> saasRoleGroups = saasRoleGroupService.listByCodes(categoryCodes, 2);
//查询角色组相关角色及配置的权限
Set<Long> roleGroupId = saasRoleGroups.stream().map(BaseEntity::getId).collect(Collectors.toSet());
List<SaasRoleGroupRelation> roleGroupRelations = saasRoleGroupRelationDao.getByGroupIds(roleGroupId);
@ -918,11 +920,21 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
Map<Long, SaasRole> roleMap = roleInfos.stream().collect(Collectors.toMap(BaseEntity::getId, Function.identity()));
Map<Long, SaasPermissionGroup> permissionGroupMap = permissionGroups.stream().collect(Collectors.toMap(BaseEntity::getId, Function.identity()));
//按查询的code分组所有group
Map<Long, List<SaasRoleGroup>> allGroupMap = saasRoleGroups.stream().collect(Collectors.groupingBy(SaasRoleGroup::getParentId));
List<SaasRoleGroup> categoryRoleGroups = saasRoleGroupService.listByCodes(categoryCodes, 1);
Map<String, List<SaasRoleGroup>> groupMap = categoryRoleGroups.stream().collect(Collectors.groupingBy(SaasRoleGroup::getCode));
for (Map.Entry<String, List<SaasRoleGroup>> entry : groupMap.entrySet()) {
Map<String, SaasRoleGroup> categoryMap = categoryRoleGroups.stream().collect(Collectors.toMap(SaasRoleGroup::getCode, Function.identity()));
Map<String, List<SaasRoleGroup>> groupsByCategory = new HashMap<>();
for (Map.Entry<String, SaasRoleGroup> entry : categoryMap.entrySet()) {
SaasRoleGroup parent = entry.getValue();
List<SaasRoleGroup> groups = groupsByCategory.getOrDefault(entry.getKey(), new ArrayList<>());
//父级和子级
groups.add(parent);
List<SaasRoleGroup> children = allGroupMap.get(parent.getId());
if (CollectionUtil.isEmpty(children)) {
groups.addAll(children);
}
groupsByCategory.put(entry.getKey(), groups);
}

View File

@ -221,6 +221,7 @@ public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, S
if (CollectionUtil.isEmpty(groups) || type == 1) {
return Collections.emptyList();
}
//TODO: 未支持多层级
List<Long> parentIds = groups.stream().map(SaasRoleGroup::getId).collect(Collectors.toList());
List<SaasRoleGroup> children = saasRoleGroupDao.lambdaQuery().eq(SaasRoleGroup::getParentId, parentIds).list();
if (type == 2) {