diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/request/OrganizationUserRoleEditRequest.java b/backend/services/system-setting/src/main/java/io/metersphere/system/request/OrganizationUserRoleEditRequest.java index 9816694af9..7c6aef3957 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/request/OrganizationUserRoleEditRequest.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/request/OrganizationUserRoleEditRequest.java @@ -32,10 +32,4 @@ public class OrganizationUserRoleEditRequest implements Serializable { @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}) 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; } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationUserRoleService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationUserRoleService.java index 6a7d9010a0..e844ca7853 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationUserRoleService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationUserRoleService.java @@ -59,6 +59,7 @@ public class OrganizationUserRoleService extends BaseUserRoleService { @Override public UserRole add(UserRole userRole) { userRole.setInternal(false); + userRole.setType(ORGANIZATION_ROLE_TYPE); checkNewRoleExist(userRole); return super.add(userRole); } @@ -69,6 +70,7 @@ public class OrganizationUserRoleService extends BaseUserRoleService { // 非组织用户组不允许修改, 内置用户组不允许修改 checkOrgUserRole(oldRole); checkInternalUserRole(oldRole); + userRole.setType(ORGANIZATION_ROLE_TYPE); checkNewRoleExist(userRole); return super.update(userRole); } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationUserRoleControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationUserRoleControllerTests.java index 7c498bd179..dac46114e4 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationUserRoleControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationUserRoleControllerTests.java @@ -86,7 +86,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest { public void testOrganizationUserRoleAddSuccess() throws Exception { OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest(); request.setName("default-org-role-5"); - request.setType(ORGANIZATION_ROLE_TYPE); request.setScopeId("default-organization-2"); MvcResult addResult = this.responsePost(ORGANIZATION_USER_ROLE_ADD, request); // 验证是否添加成功 @@ -109,7 +108,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest { OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest(); // 同名用户组已存在 request.setName("default-org-role-2"); - request.setType(ORGANIZATION_ROLE_TYPE); request.setScopeId("default-organization-2"); this.requestPost(ORGANIZATION_USER_ROLE_ADD, request, status().is5xxServerError()); } @@ -133,7 +131,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest { request = new OrganizationUserRoleEditRequest(); request.setId("default-org-role-id-2"); request.setName("组织管理员"); - request.setType(ORGANIZATION_ROLE_TYPE); request.setScopeId("default-organization-2"); this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request, status().is5xxServerError()); } @@ -144,7 +141,6 @@ public class OrganizationUserRoleControllerTests extends BaseTest { OrganizationUserRoleEditRequest request = new OrganizationUserRoleEditRequest(); request.setId("default-org-role-id-2"); request.setName("default-org-role-x"); - request.setType(ORGANIZATION_ROLE_TYPE); request.setScopeId("default-organization-2"); this.requestPost(ORGANIZATION_USER_ROLE_UPDATE, request, status().isOk()); // 验证是否修改成功