feat:(REQ-2750) 修改项目负责人更新成admin后的用户更新角色接口
This commit is contained in:
parent
7b08981945
commit
a1bedadf51
@ -41,6 +41,9 @@ public class FeignConfig implements RequestInterceptor, EnvironmentAware {
|
||||
@Value("${apisixUrl:http://dev-app.axzo.cn/apisix-plat}")
|
||||
private String apisixUrl;
|
||||
|
||||
@Value("${workspace:http://dev-app.axzo.cn/workspace}")
|
||||
private String workspaceUrl;
|
||||
|
||||
private static String POD_NAMESPACE;
|
||||
static {
|
||||
Map<String, String> env = System.getenv();
|
||||
@ -63,6 +66,7 @@ public class FeignConfig implements RequestInterceptor, EnvironmentAware {
|
||||
url = url.replace("http://maokai:8080", maokaiEnvUrl);
|
||||
url = url.replace("http://pudge:10099", pudgeEnvUrl);
|
||||
url = url.replace("http://apisix-plat:8080", apisixUrl);
|
||||
url = url.replace("http://workspace:8080", workspaceUrl);
|
||||
|
||||
String profile = environment.getProperty("spring.profiles.active");
|
||||
if(Objects.equals(profile, "test") && url.contains("dev-app.axzo.cn")) {
|
||||
|
||||
@ -191,10 +191,14 @@ public class RoleUserService implements SaasRoleUserService {
|
||||
checkJobRole(req);
|
||||
|
||||
Set<Long> updateRoleIds = req.getUpdateRoleIds();
|
||||
// 特殊角色,因为特殊角色不会在用户端回显,编辑后会被覆盖导致角色错误
|
||||
Set<Long> specialRoleIds = new HashSet<>(this.getSpecialRole());
|
||||
// 角色校验(不能将角色修改为管理员角色)
|
||||
if (CollectionUtils.isNotEmpty(updateRoleIds)) {
|
||||
List<SaasRole> roles = saasRoleDao.listByIds(updateRoleIds);
|
||||
if (roles.stream().anyMatch(e -> RoleTypeEnum.getRoleType(e.getRoleType()).isAdminRole())) {
|
||||
if (roles.stream()
|
||||
.filter(e -> !specialRoleIds.contains(e.getId()))
|
||||
.anyMatch(e -> RoleTypeEnum.getRoleType(e.getRoleType()).isAdminRole())) {
|
||||
throw new ServiceException("暂不支持更换/移除管理员角色");
|
||||
}
|
||||
}
|
||||
@ -213,15 +217,15 @@ public class RoleUserService implements SaasRoleUserService {
|
||||
if (CollectionUtils.isNotEmpty(saasRoleUsers)) {
|
||||
List<SaasRole> existsRole = saasRoleDao.listByIds(saasRoleUsers.stream().mapToLong(SaasRoleUserV2DTO::getRoleId).boxed().collect(Collectors.toList()));
|
||||
// 管理员角色
|
||||
List<Long> adminRole = existsRole.stream().filter(e -> RoleTypeEnum.getRoleType(e.getRoleType()).isAdminRole()).mapToLong(SaasRole::getId).boxed().collect(Collectors.toList());
|
||||
List<Long> adminRole = existsRole.stream()
|
||||
.filter(e -> !specialRoleIds.contains(e.getId()))
|
||||
.filter(e -> RoleTypeEnum.getRoleType(e.getRoleType()).isAdminRole())
|
||||
.mapToLong(SaasRole::getId).boxed().collect(Collectors.toList());
|
||||
// 自定义角色
|
||||
Long autoOwnRole = existsRole.stream().filter(e -> RoleTypeEnum.AUTO_OWN.equals(RoleTypeEnum.getRoleType(e.getRoleType()))).findFirst().map(SaasRole::getId).orElse(0L);
|
||||
log.info("personId:{} autoOwnRole:{} adminRole:{}", req.getPersonId(), autoOwnRole, JSONUtil.toJsonStr(adminRole));
|
||||
// 排除管理员角色、自定义角色(普通角色) 这里用过滤的方式,是为了防止脏数据产生(saas_role_user_relation表有用户数据但是角色表已经被删除)
|
||||
|
||||
// 特殊角色,因为特殊角色不会在用户端回显,编辑后会被覆盖导致角色错误
|
||||
Set<Long> specialRoleIds = new HashSet<>(this.getSpecialRole());
|
||||
|
||||
notAdminAndAutoOwnRole = saasRoleUsers.stream()
|
||||
.mapToLong(SaasRoleUserV2DTO::getRoleId)
|
||||
.boxed()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user