fix(系统设置): 组织用户组移除类型字段

This commit is contained in:
song-cc-rock 2023-08-24 16:58:30 +08:00 committed by 刘瑞斌
parent 32cd28176e
commit 5b5fa2ab30
3 changed files with 2 additions and 10 deletions

View File

@ -32,10 +32,4 @@ public class OrganizationUserRoleEditRequest implements Serializable {
@NotBlank(message = "{user_role.scope_id.not_blank}", groups = {Created.class, Updated.class}) @NotBlank(message = "{user_role.scope_id.not_blank}", groups = {Created.class, Updated.class})
@Size(min = 1, max = 50, message = "{user_role.scope_id.length_range}", groups = {Created.class, Updated.class}) @Size(min = 1, max = 50, message = "{user_role.scope_id.length_range}", groups = {Created.class, Updated.class})
private String scopeId; private String scopeId;
@Schema(description = "所属类型 SYSTEM ORGANIZATION PROJECT", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "{user_role.type.not_blank}", groups = {Created.class, Updated.class})
@EnumValue(enumClass = UserRoleType.class, groups = {Created.class, Updated.class})
@Size(min = 1, max = 20, message = "{user_role.type.length_range}", groups = {Created.class, Updated.class})
private String type;
} }

View File

@ -59,6 +59,7 @@ public class OrganizationUserRoleService extends BaseUserRoleService {
@Override @Override
public UserRole add(UserRole userRole) { public UserRole add(UserRole userRole) {
userRole.setInternal(false); userRole.setInternal(false);
userRole.setType(ORGANIZATION_ROLE_TYPE);
checkNewRoleExist(userRole); checkNewRoleExist(userRole);
return super.add(userRole); return super.add(userRole);
} }
@ -69,6 +70,7 @@ public class OrganizationUserRoleService extends BaseUserRoleService {
// 非组织用户组不允许修改, 内置用户组不允许修改 // 非组织用户组不允许修改, 内置用户组不允许修改
checkOrgUserRole(oldRole); checkOrgUserRole(oldRole);
checkInternalUserRole(oldRole); checkInternalUserRole(oldRole);
userRole.setType(ORGANIZATION_ROLE_TYPE);
checkNewRoleExist(userRole); checkNewRoleExist(userRole);
return super.update(userRole); return super.update(userRole);
} }

View File

@ -86,7 +86,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
public void testOrganizationUserRoleAddSuccess() throws Exception { public void testOrganizationUserRoleAddSuccess() throws Exception {
OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest(); OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest();
request.setName("default-org-role-5"); request.setName("default-org-role-5");
request.setType(ORGANIZATION_ROLE_TYPE);
request.setScopeId("default-organization-2"); request.setScopeId("default-organization-2");
MvcResult addResult = this.responsePost(ORGANIZATION_USER_ROLE_ADD, request); MvcResult addResult = this.responsePost(ORGANIZATION_USER_ROLE_ADD, request);
// 验证是否添加成功 // 验证是否添加成功
@ -109,7 +108,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest(); OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest();
// 同名用户组已存在 // 同名用户组已存在
request.setName("default-org-role-2"); request.setName("default-org-role-2");
request.setType(ORGANIZATION_ROLE_TYPE);
request.setScopeId("default-organization-2"); request.setScopeId("default-organization-2");
this.requestPost(ORGANIZATION_USER_ROLE_ADD, request, status().is5xxServerError()); this.requestPost(ORGANIZATION_USER_ROLE_ADD, request, status().is5xxServerError());
} }
@ -133,7 +131,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
request = new OrganizationUserRoleEditRequest(); request = new OrganizationUserRoleEditRequest();
request.setId("default-org-role-id-2"); request.setId("default-org-role-id-2");
request.setName("组织管理员"); request.setName("组织管理员");
request.setType(ORGANIZATION_ROLE_TYPE);
request.setScopeId("default-organization-2"); request.setScopeId("default-organization-2");
this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request, status().is5xxServerError()); this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request, status().is5xxServerError());
} }
@ -144,7 +141,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest {
OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest(); OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest();
request.setId("default-org-role-id-2"); request.setId("default-org-role-id-2");
request.setName("default-org-role-x"); request.setName("default-org-role-x");
request.setType(ORGANIZATION_ROLE_TYPE);
request.setScopeId("default-organization-2"); request.setScopeId("default-organization-2");
this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request, status().isOk()); this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request, status().isOk());
// 验证是否修改成功 // 验证是否修改成功