REQ-2046 小组长权限
This commit is contained in:
parent
a3a0eee25e
commit
13c7b79591
@ -140,5 +140,4 @@ public interface TyrSaasRoleApi {
|
||||
*/
|
||||
@PostMapping("api/saasRole/changeGroupLeaderRole")
|
||||
ApiResult<Void> changeGroupLeaderRole(@RequestBody @Valid List<ChangeGroupLeaderRoleReq> req);
|
||||
|
||||
}
|
||||
|
||||
@ -42,5 +42,5 @@ public class ChangeGroupLeaderRoleReq {
|
||||
* 权限名列表
|
||||
*/
|
||||
@NotEmpty
|
||||
private List<String> permissionNameList = Lists.newArrayListWithExpectedSize(3);
|
||||
private List<Long> roleIdList = Lists.newArrayList();
|
||||
}
|
||||
|
||||
@ -886,20 +886,18 @@ public class RoleServiceImpl implements RoleService {
|
||||
log.warn("can't find group_role_relation.code: {}", groupLeaderCode);
|
||||
return;
|
||||
}
|
||||
Map<String, Long> roleMap = voList.get(0).getRoleInfos().stream().collect(Collectors.toMap(SaasRoleVO::getName, SaasRoleVO::getId, (a, b) -> a));
|
||||
|
||||
List<SaasRoleUserRelation> userRelationList = reqs.stream().map(req -> {
|
||||
List<SaasRoleUserRelation> nowRelations = saasRoleUserRelationDao.findValidByNodeResource(req.getGroupLeaderPersonId(), req.getGroupNodeId(), null);
|
||||
Map<Long, SaasRoleUserRelation> relationMap = nowRelations.stream().collect(Collectors.toMap(SaasRoleUserRelation::getRoleId, Function.identity(), (a, b) -> a));
|
||||
List<String> permissionNameList = req.getPermissionNameList();
|
||||
if (CollUtil.isNotEmpty(permissionNameList)) {
|
||||
List<Long> roleIdList = req.getRoleIdList();
|
||||
if (CollUtil.isNotEmpty(roleIdList)) {
|
||||
if (CollUtil.isNotEmpty(nowRelations)) {
|
||||
List<SaasRoleUserRelation> resList = Lists.newArrayList();
|
||||
// 都不为空 既增又减
|
||||
Set<Long> nowRoles = nowRelations.stream().map(SaasRoleUserRelation::getRoleId).collect(Collectors.toSet());
|
||||
// nowRoles -A , newRoles - B
|
||||
// A-B 减少的权限
|
||||
Set<Long> newRoles = permissionNameList.stream().map(roleMap::get).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<Long> newRoles = roleIdList.stream().filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Set<Long> deductRoles = Sets.difference(nowRoles, newRoles);
|
||||
if (CollUtil.isNotEmpty(deductRoles)) {
|
||||
List<SaasRoleUserRelation> deductRelations = deductRoles.stream().map(relationMap::get).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
@ -927,14 +925,11 @@ public class RoleServiceImpl implements RoleService {
|
||||
return resList;
|
||||
} else {
|
||||
// nowRelations 为空 则只增不减
|
||||
return permissionNameList.stream().map(e -> {
|
||||
if (Objects.isNull(roleMap.get(e))) {
|
||||
return null;
|
||||
}
|
||||
return roleIdList.stream().map(e -> {
|
||||
SaasRoleUserRelation userRelation = new SaasRoleUserRelation();
|
||||
|
||||
userRelation.setIdentityId(req.getGroupLeaderIdentityId());
|
||||
userRelation.setRoleId(roleMap.get(e));
|
||||
userRelation.setRoleId(e);
|
||||
userRelation.setIdentityType(IdentityType.WORKER.getCode());
|
||||
userRelation.setNaturalPersonId(req.getGroupLeaderPersonId());
|
||||
userRelation.setWorkspaceId(req.getWorkspaceId());
|
||||
@ -944,7 +939,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
userRelation.setResourceId(req.getGroupNodeId());
|
||||
|
||||
return userRelation;
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(nowRelations)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user