fix(项目设置): 修改内置字段名称后,名称无法国际化

This commit is contained in:
AgAngle 2024-01-22 19:22:29 +08:00 committed by Craftsman
parent 036f580204
commit 4f6cbed856
4 changed files with 14 additions and 8 deletions

View File

@ -52,7 +52,7 @@ public class ProjectCustomFieldService extends BaseCustomFieldService {
CustomField originCustomField = getWithCheck(customField.getId()); CustomField originCustomField = getWithCheck(customField.getId());
if (originCustomField.getInternal()) { if (originCustomField.getInternal()) {
// 内置字段不能修改名字 // 内置字段不能修改名字
originCustomField.setName(null); customField.setName(null);
} }
customField.setScopeId(originCustomField.getScopeId()); customField.setScopeId(originCustomField.getScopeId());
Project project = projectService.checkResourceExist(originCustomField.getScopeId()); Project project = projectService.checkResourceExist(originCustomField.getScopeId());

View File

@ -177,10 +177,13 @@ public class ProjectCustomFieldControllerTests extends BaseTest {
} }
CustomFieldExample example = new CustomFieldExample(); CustomFieldExample example = new CustomFieldExample();
example.createCriteria().andScopeIdEqualTo(DEFAULT_PROJECT_ID).andInternalEqualTo(true); example.createCriteria().andScopeIdEqualTo(DEFAULT_PROJECT_ID).andNameEqualTo("functional_priority");
request = BeanUtils.copyBean(request, customFieldMapper.selectByExample(example).get(0)); CustomFieldUpdateRequest internalRequest = BeanUtils.copyBean(new CustomFieldUpdateRequest(), customFieldMapper.selectByExample(example).get(0));
this.requestPostWithOk(DEFAULT_UPDATE, request); internalRequest.setName("aaaa");
this.requestPostWithOk(DEFAULT_UPDATE, internalRequest);
Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getInternal(), true); Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getInternal(), true);
// 内置字段名称不能修改
Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getName(), "functional_priority");
// @校验是否开启项目模板 // @校验是否开启项目模板
changeOrgTemplateEnable(true); changeOrgTemplateEnable(true);

View File

@ -83,7 +83,7 @@ public class OrganizationCustomFieldService extends BaseCustomFieldService {
CustomField originCustomField = getWithCheck(customField.getId()); CustomField originCustomField = getWithCheck(customField.getId());
if (originCustomField.getInternal()) { if (originCustomField.getInternal()) {
// 内置字段不能修改名字 // 内置字段不能修改名字
originCustomField.setName(null); customField.setName(null);
} }
checkOrganizationTemplateEnable(customField.getScopeId(), originCustomField.getScene()); checkOrganizationTemplateEnable(customField.getScopeId(), originCustomField.getScene());
customField.setScopeId(originCustomField.getScopeId()); customField.setScopeId(originCustomField.getScopeId());

View File

@ -182,10 +182,13 @@ public class OrganizationCustomFieldControllerTests extends BaseTest {
assertRefCustomField(customField); assertRefCustomField(customField);
CustomFieldExample example = new CustomFieldExample(); CustomFieldExample example = new CustomFieldExample();
example.createCriteria().andScopeIdEqualTo(DEFAULT_ORGANIZATION_ID).andInternalEqualTo(true); example.createCriteria().andScopeIdEqualTo(DEFAULT_ORGANIZATION_ID).andNameEqualTo("functional_priority");
request = BeanUtils.copyBean(request, customFieldMapper.selectByExample(example).get(0)); CustomFieldUpdateRequest internalRequest = BeanUtils.copyBean(new CustomFieldUpdateRequest(), customFieldMapper.selectByExample(example).get(0));
this.requestPostWithOk(DEFAULT_UPDATE, request); internalRequest.setName("aaaa");
this.requestPostWithOk(DEFAULT_UPDATE, internalRequest);
Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getInternal(), true); Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getInternal(), true);
// 内置字段名称不能修改
Assertions.assertEquals(customFieldMapper.selectByExample(example).get(0).getName(), "functional_priority");
// @校验是否开启组织模板 // @校验是否开启组织模板
changeOrgTemplateEnable(false); changeOrgTemplateEnable(false);