refactor(系统设置): 获取自定义字段接口,添加内置字段的key

This commit is contained in:
AgAngle 2024-06-26 14:35:27 +08:00 committed by 刘瑞斌
parent b1ad7f87d8
commit 31bae66c01
3 changed files with 7 additions and 0 deletions

View File

@ -17,4 +17,8 @@ public class CustomFieldDTO extends CustomField {
* 模板中该字段是否必选 * 模板中该字段是否必选
*/ */
private Boolean templateRequired = false; private Boolean templateRequired = false;
/**
* 内置字段的 key
*/
private String internalFieldKey;
} }

View File

@ -93,6 +93,7 @@ public class BaseCustomFieldService {
.map(TemplateRequiredCustomField::getName) .map(TemplateRequiredCustomField::getName)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
customFieldDTO.setTemplateRequired(templateRequiredCustomFieldSet.contains(item.getName())); customFieldDTO.setTemplateRequired(templateRequiredCustomFieldSet.contains(item.getName()));
customFieldDTO.setInternalFieldKey(item.getName());
// 翻译内置字段名称 // 翻译内置字段名称
customFieldDTO.setName(translateInternalField(item.getName())); customFieldDTO.setName(translateInternalField(item.getName()));
} }
@ -129,6 +130,7 @@ public class BaseCustomFieldService {
BeanUtils.copyBean(customFieldDTO, customField); BeanUtils.copyBean(customFieldDTO, customField);
customFieldDTO.setOptions(baseCustomFieldOptionService.getByFieldId(customFieldDTO.getId())); customFieldDTO.setOptions(baseCustomFieldOptionService.getByFieldId(customFieldDTO.getId()));
if (customField.getInternal()) { if (customField.getInternal()) {
customFieldDTO.setInternalFieldKey(customField.getName());
customField.setName(translateInternalField(customField.getName())); customField.setName(translateInternalField(customField.getName()));
} }
return customFieldDTO; return customFieldDTO;

View File

@ -251,6 +251,7 @@ public class OrganizationCustomFieldControllerTests extends BaseTest {
CustomField customField = customFields.get(i); CustomField customField = customFields.get(i);
customField.setCreateUser(userNameMap.get(customField.getCreateUser())); customField.setCreateUser(userNameMap.get(customField.getCreateUser()));
if (customField.getInternal()) { if (customField.getInternal()) {
Assertions.assertEquals(customFieldDTO.getInternalFieldKey(), customField.getName());
// 校验内置用户名称是否翻译 // 校验内置用户名称是否翻译
customField.setName(baseCustomFieldService.translateInternalField(customField.getName())); customField.setName(baseCustomFieldService.translateInternalField(customField.getName()));
} }