From f494bcf0015100ea7ad7137f3dcf1271d7ebb4f6 Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Wed, 25 Oct 2023 16:41:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97=E6=AE=B5=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=92=8C=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/sdk/dto/request/CustomFieldUpdateRequest.java | 3 +++ .../project/controller/ProjectCustomFieldControllerTests.java | 2 ++ .../io/metersphere/system/service/BaseCustomFieldService.java | 1 + .../controller/OrganizationCustomFieldControllerTests.java | 2 ++ 4 files changed, 8 insertions(+) diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/request/CustomFieldUpdateRequest.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/request/CustomFieldUpdateRequest.java index cb9d63c000..b75f0dcc58 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/request/CustomFieldUpdateRequest.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/request/CustomFieldUpdateRequest.java @@ -45,6 +45,9 @@ public class CustomFieldUpdateRequest { @Size(min = 1, max = 50, message = "{custom_field.scope_id.length_range}", groups = {Created.class}) private String scopeId; + @Schema(description = "是否需要手动输入选项key") + private Boolean enableOptionKey; + @Valid @Schema(title = "自定义字段选项") private List options; diff --git a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectCustomFieldControllerTests.java b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectCustomFieldControllerTests.java index ac6de55927..ac4c79bc08 100644 --- a/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectCustomFieldControllerTests.java +++ b/backend/services/project-management/src/test/java/io/metersphere/project/controller/ProjectCustomFieldControllerTests.java @@ -87,6 +87,7 @@ public class ProjectCustomFieldControllerTests extends BaseTest { CustomFieldOptionRequest customFieldOptionRequest = new CustomFieldOptionRequest(); customFieldOptionRequest.setValue("1111"); customFieldOptionRequest.setText("test"); + request.setEnableOptionKey(true); List optionRequests = Arrays.asList(customFieldOptionRequest); request.setOptions(optionRequests); @@ -149,6 +150,7 @@ public class ProjectCustomFieldControllerTests extends BaseTest { request.setType(CustomFieldType.SELECT.name()); request.setRemark("AAA1"); request.setScopeId("1111"); + request.setEnableOptionKey(false); CustomFieldOptionRequest customFieldOptionRequest = new CustomFieldOptionRequest(); customFieldOptionRequest.setValue("11112"); customFieldOptionRequest.setText("test1"); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseCustomFieldService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseCustomFieldService.java index ac40b599ee..953719109c 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseCustomFieldService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseCustomFieldService.java @@ -127,6 +127,7 @@ public class BaseCustomFieldService { customField.setId(IDGenerator.nextStr()); customField.setCreateTime(System.currentTimeMillis()); customField.setUpdateTime(System.currentTimeMillis()); + customField.setEnableOptionKey(BooleanUtils.isTrue(customField.getEnableOptionKey())); customFieldMapper.insert(customField); baseCustomFieldOptionService.addByFieldId(customField.getId(), options); return customField; diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationCustomFieldControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationCustomFieldControllerTests.java index 82376600b0..aca0475ca8 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationCustomFieldControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationCustomFieldControllerTests.java @@ -90,6 +90,7 @@ public class OrganizationCustomFieldControllerTests extends BaseTest { request.setType(CustomFieldType.SELECT.name()); request.setRemark("AAA"); request.setScopeId(DEFAULT_ORGANIZATION_ID); + request.setEnableOptionKey(true); CustomFieldOptionRequest customFieldOptionRequest = new CustomFieldOptionRequest(); customFieldOptionRequest.setValue("1111"); customFieldOptionRequest.setText("test"); @@ -156,6 +157,7 @@ public class OrganizationCustomFieldControllerTests extends BaseTest { request.setType(CustomFieldType.SELECT.name()); request.setRemark("AAA1"); request.setScopeId("1111"); + request.setEnableOptionKey(false); CustomFieldOptionRequest customFieldOptionRequest = new CustomFieldOptionRequest(); customFieldOptionRequest.setValue("11112"); customFieldOptionRequest.setText("test1");