From f42075ceb9d1d064688e321227719b71a0b250ba Mon Sep 17 00:00:00 2001 From: AgAngle <1323481023@qq.com> Date: Fri, 19 Jan 2024 20:30:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8E=E5=8F=98=E6=88=90=E4=BA=86=E9=9D=9E?= =?UTF-8?q?=E5=86=85=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/service/ProjectCustomFieldService.java | 4 ++++ .../controller/ProjectCustomFieldControllerTests.java | 6 ++++++ .../system/dto/request/DefaultFunctionalCustomField.java | 4 ++-- .../metersphere/system/service/BaseCustomFieldService.java | 2 +- .../system/service/OrganizationCustomFieldService.java | 4 ++++ .../controller/OrganizationCustomFieldControllerTests.java | 6 ++++++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectCustomFieldService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectCustomFieldService.java index 0611965678..488de8d27b 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectCustomFieldService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ProjectCustomFieldService.java @@ -50,6 +50,10 @@ public class ProjectCustomFieldService extends BaseCustomFieldService { @Override public CustomField update(CustomField customField, List options) { CustomField originCustomField = getWithCheck(customField.getId()); + if (originCustomField.getInternal()) { + // 内置字段不能修改名字 + originCustomField.setName(null); + } customField.setScopeId(originCustomField.getScopeId()); Project project = projectService.checkResourceExist(originCustomField.getScopeId()); checkProjectTemplateEnable(project.getOrganizationId(), originCustomField.getScene()); 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 0a433978a0..8a97c04ff2 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 @@ -176,6 +176,12 @@ public class ProjectCustomFieldControllerTests extends BaseTest { Assertions.assertEquals(customField.getId(), optionItem.getFieldId()); } + CustomFieldExample example = new CustomFieldExample(); + example.createCriteria().andScopeIdEqualTo(DEFAULT_PROJECT_ID).andInternalEqualTo(true); + request = BeanUtils.copyBean(request, customFieldMapper.selectByExample(example).get(0)); + this.requestPostWithOk(DEFAULT_UPDATE, request); + Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getInternal(), true); + // @校验是否开启项目模板 changeOrgTemplateEnable(true); assertErrorCode(this.requestPost(DEFAULT_ADD, request), PROJECT_TEMPLATE_PERMISSION); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/DefaultFunctionalCustomField.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/DefaultFunctionalCustomField.java index 94401e8c67..8b7eff1341 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/DefaultFunctionalCustomField.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/DefaultFunctionalCustomField.java @@ -14,10 +14,10 @@ public enum DefaultFunctionalCustomField { PRIORITY("functional_priority", CustomFieldType.SELECT, Arrays.asList( + getNewOption("P0", "P0"), getNewOption("P1", "P1"), getNewOption("P2", "P2"), - getNewOption("P3", "P3"), - getNewOption("P4", "P4") + getNewOption("P3", "P3") ) ); 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 5acf048675..0c1ab49953 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 @@ -144,7 +144,7 @@ public class BaseCustomFieldService { customField.setScopeId(null); customField.setScene(null); customField.setScopeType(null); - customField.setInternal(false); + customField.setInternal(null); customField.setCreateUser(null); customField.setCreateTime(null); customField.setType(null); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationCustomFieldService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationCustomFieldService.java index a3d65a4107..3d62a198f8 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationCustomFieldService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationCustomFieldService.java @@ -81,6 +81,10 @@ public class OrganizationCustomFieldService extends BaseCustomFieldService { @Override public CustomField update(CustomField customField, List options) { CustomField originCustomField = getWithCheck(customField.getId()); + if (originCustomField.getInternal()) { + // 内置字段不能修改名字 + originCustomField.setName(null); + } checkOrganizationTemplateEnable(customField.getScopeId(), originCustomField.getScene()); customField.setScopeId(originCustomField.getScopeId()); OrganizationService.checkResourceExist(originCustomField.getScopeId()); 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 d71829f395..a0b8e3eeba 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 @@ -181,6 +181,12 @@ public class OrganizationCustomFieldControllerTests extends BaseTest { } assertRefCustomField(customField); + CustomFieldExample example = new CustomFieldExample(); + example.createCriteria().andScopeIdEqualTo(DEFAULT_ORGANIZATION_ID).andInternalEqualTo(true); + request = BeanUtils.copyBean(request, customFieldMapper.selectByExample(example).get(0)); + this.requestPostWithOk(DEFAULT_UPDATE, request); + Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getInternal(), true); + // @校验是否开启组织模板 changeOrgTemplateEnable(false); assertErrorCode(this.requestPost(DEFAULT_UPDATE, request), ORGANIZATION_TEMPLATE_PERMISSION);