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");