fix(项目设置): 内置自定义字段修改后变成了非内置
This commit is contained in:
parent
a194dc7b7f
commit
f42075ceb9
|
@ -50,6 +50,10 @@ public class ProjectCustomFieldService extends BaseCustomFieldService {
|
|||
@Override
|
||||
public CustomField update(CustomField customField, List<CustomFieldOptionRequest> 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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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")
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -81,6 +81,10 @@ public class OrganizationCustomFieldService extends BaseCustomFieldService {
|
|||
@Override
|
||||
public CustomField update(CustomField customField, List<CustomFieldOptionRequest> 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());
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue