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