feat:(REQ-2227) 修改通过category查询角色的bug

This commit is contained in:
lilong 2024-04-19 14:19:30 +08:00
parent 4255dabb64
commit 4e594c02a4
2 changed files with 11 additions and 2 deletions

View File

@ -949,7 +949,7 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
//父级和子级 //父级和子级
groups.add(parent); groups.add(parent);
List<SaasRoleGroup> children = allGroupMap.get(parent.getId()); List<SaasRoleGroup> children = allGroupMap.get(parent.getId());
if (CollectionUtil.isEmpty(children)) { if (CollectionUtil.isNotEmpty(children)) {
groups.addAll(children); groups.addAll(children);
} }
groupsByCategory.put(entry.getKey(), groups); groupsByCategory.put(entry.getKey(), groups);
@ -968,6 +968,7 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
List<Long> groupIdList = g.getValue().stream().map(SaasRoleGroup::getId).collect(Collectors.toList()); List<Long> groupIdList = g.getValue().stream().map(SaasRoleGroup::getId).collect(Collectors.toList());
List<SaasRoleGroupRelation> roleGroupRelationList = groupIdList.stream().map(groupByGroupId::get) List<SaasRoleGroupRelation> roleGroupRelationList = groupIdList.stream().map(groupByGroupId::get)
.filter(Objects::nonNull)
.flatMap((Function<List<SaasRoleGroupRelation>, Stream<SaasRoleGroupRelation>>) saasRoleGroupRelations -> saasRoleGroupRelations.stream().map(saasRoleGroupRelation -> saasRoleGroupRelation)) .flatMap((Function<List<SaasRoleGroupRelation>, Stream<SaasRoleGroupRelation>>) saasRoleGroupRelations -> saasRoleGroupRelations.stream().map(saasRoleGroupRelation -> saasRoleGroupRelation))
.collect(Collectors.toList()); .collect(Collectors.toList());
List<Long> roleIdList = roleGroupRelationList.stream().map(SaasRoleGroupRelation::getRoleId).collect(Collectors.toList()); List<Long> roleIdList = roleGroupRelationList.stream().map(SaasRoleGroupRelation::getRoleId).collect(Collectors.toList());

View File

@ -215,11 +215,19 @@ public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, S
} }
} }
/**
* type = 1:只查询code匹配到的数据
* type = 2:查询code匹配到的数据和子节点的数据
* type = 3:只查询code匹配到的数据的子节点数据
* @param codes 角色组编码
* @param type 1-仅查当前code 2-对应code角色组及子级角色组 3-仅对应code角色组的子级
* @return
*/
@Override @Override
public List<SaasRoleGroup> listByCodes(List<String> codes, int type) { public List<SaasRoleGroup> listByCodes(List<String> codes, int type) {
List<SaasRoleGroup> groups = saasRoleGroupDao.listByCodes(codes); List<SaasRoleGroup> groups = saasRoleGroupDao.listByCodes(codes);
if (CollectionUtil.isEmpty(groups) || type == 1) { if (CollectionUtil.isEmpty(groups) || type == 1) {
return Collections.emptyList(); return groups;
} }
//TODO: 未支持多层级 //TODO: 未支持多层级
List<Long> parentIds = groups.stream().map(SaasRoleGroup::getId).collect(Collectors.toList()); List<Long> parentIds = groups.stream().map(SaasRoleGroup::getId).collect(Collectors.toList());