From 31bae66c0172247959bd636036e1f3f0c30b42fd Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Wed, 26 Jun 2024 14:35:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E8=8E=B7=E5=8F=96=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=86=85?= =?UTF-8?q?=E7=BD=AE=E5=AD=97=E6=AE=B5=E7=9A=84key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/system/dto/sdk/CustomFieldDTO.java | 4 ++++ .../io/metersphere/system/service/BaseCustomFieldService.java | 2 ++ .../controller/OrganizationCustomFieldControllerTests.java | 1 + 3 files changed, 7 insertions(+) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CustomFieldDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CustomFieldDTO.java index 772d28b03c..ec897ec919 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CustomFieldDTO.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CustomFieldDTO.java @@ -17,4 +17,8 @@ public class CustomFieldDTO extends CustomField { * 模板中该字段是否必选 */ private Boolean templateRequired = false; + /** + * 内置字段的 key + */ + private String internalFieldKey; } 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 63d64d1bdc..d300768f21 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 @@ -93,6 +93,7 @@ public class BaseCustomFieldService { .map(TemplateRequiredCustomField::getName) .collect(Collectors.toSet()); customFieldDTO.setTemplateRequired(templateRequiredCustomFieldSet.contains(item.getName())); + customFieldDTO.setInternalFieldKey(item.getName()); // 翻译内置字段名称 customFieldDTO.setName(translateInternalField(item.getName())); } @@ -129,6 +130,7 @@ public class BaseCustomFieldService { BeanUtils.copyBean(customFieldDTO, customField); customFieldDTO.setOptions(baseCustomFieldOptionService.getByFieldId(customFieldDTO.getId())); if (customField.getInternal()) { + customFieldDTO.setInternalFieldKey(customField.getName()); customField.setName(translateInternalField(customField.getName())); } return customFieldDTO; 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 2cc35c6770..57261f1860 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 @@ -251,6 +251,7 @@ public class OrganizationCustomFieldControllerTests extends BaseTest { CustomField customField = customFields.get(i); customField.setCreateUser(userNameMap.get(customField.getCreateUser())); if (customField.getInternal()) { + Assertions.assertEquals(customFieldDTO.getInternalFieldKey(), customField.getName()); // 校验内置用户名称是否翻译 customField.setName(baseCustomFieldService.translateInternalField(customField.getName())); }