diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/feign/TyrSaasRoleApi.java b/tyr-api/src/main/java/cn/axzo/tyr/client/feign/TyrSaasRoleApi.java index 412a91b0..f6de9e38 100644 --- a/tyr-api/src/main/java/cn/axzo/tyr/client/feign/TyrSaasRoleApi.java +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/feign/TyrSaasRoleApi.java @@ -140,5 +140,4 @@ public interface TyrSaasRoleApi { */ @PostMapping("api/saasRole/changeGroupLeaderRole") ApiResult changeGroupLeaderRole(@RequestBody @Valid List req); - } diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/ChangeGroupLeaderRoleReq.java b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/ChangeGroupLeaderRoleReq.java index 4fff7058..7787ea9d 100644 --- a/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/ChangeGroupLeaderRoleReq.java +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/model/req/ChangeGroupLeaderRoleReq.java @@ -42,5 +42,5 @@ public class ChangeGroupLeaderRoleReq { * 权限名列表 */ @NotEmpty - private List permissionNameList = Lists.newArrayListWithExpectedSize(3); + private List roleIdList = Lists.newArrayList(); } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/RoleServiceImpl.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/RoleServiceImpl.java index dda21a53..dda38ee3 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/RoleServiceImpl.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/RoleServiceImpl.java @@ -886,20 +886,18 @@ public class RoleServiceImpl implements RoleService { log.warn("can't find group_role_relation.code: {}", groupLeaderCode); return; } - Map roleMap = voList.get(0).getRoleInfos().stream().collect(Collectors.toMap(SaasRoleVO::getName, SaasRoleVO::getId, (a, b) -> a)); - List userRelationList = reqs.stream().map(req -> { List nowRelations = saasRoleUserRelationDao.findValidByNodeResource(req.getGroupLeaderPersonId(), req.getGroupNodeId(), null); Map relationMap = nowRelations.stream().collect(Collectors.toMap(SaasRoleUserRelation::getRoleId, Function.identity(), (a, b) -> a)); - List permissionNameList = req.getPermissionNameList(); - if (CollUtil.isNotEmpty(permissionNameList)) { + List roleIdList = req.getRoleIdList(); + if (CollUtil.isNotEmpty(roleIdList)) { if (CollUtil.isNotEmpty(nowRelations)) { List resList = Lists.newArrayList(); // 都不为空 既增又减 Set nowRoles = nowRelations.stream().map(SaasRoleUserRelation::getRoleId).collect(Collectors.toSet()); // nowRoles -A , newRoles - B // A-B 减少的权限 - Set newRoles = permissionNameList.stream().map(roleMap::get).filter(Objects::nonNull).collect(Collectors.toSet()); + Set newRoles = roleIdList.stream().filter(Objects::nonNull).collect(Collectors.toSet()); Set deductRoles = Sets.difference(nowRoles, newRoles); if (CollUtil.isNotEmpty(deductRoles)) { List 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)) {