From 5b5fa2ab30eff3e18d53efc1066dc15422e1103c Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Thu, 24 Aug 2023 16:58:30 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=94=A8=E6=88=B7=E7=BB=84=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/request/OrganizationUserRoleEditRequest.java | 6 ------ .../system/service/OrganizationUserRoleService.java | 2 ++ .../controller/OrganizationUserRoleControllerTests.java | 4 ---- 3 files changed, 2 insertions(+), 10 deletions(-) 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()); // 验证是否修改成功