refactor(系统设置): 功能用例和缺陷获取自定义字段接口,添加内置字段的key
This commit is contained in:
parent
d7142366b4
commit
7a018b2402
|
@ -27,6 +27,9 @@ public class CustomFieldOptions implements Serializable {
|
|||
@Schema(description = "是否内置字段")
|
||||
private Boolean internal;
|
||||
|
||||
@Schema(description = "内置字段的 key")
|
||||
private String internalFieldKey;
|
||||
|
||||
@Schema(description = "自定义字段选项值")
|
||||
private List<CustomFieldOption> options;
|
||||
}
|
||||
|
|
|
@ -424,6 +424,7 @@ public class ProjectTemplateService extends BaseTemplateService {
|
|||
CustomFieldOptions optionDTO = new CustomFieldOptions();
|
||||
optionDTO.setId(customField.getId());
|
||||
if (customField.getInternal()) {
|
||||
optionDTO.setInternalFieldKey(customField.getName());
|
||||
optionDTO.setName(baseCustomFieldService.translateInternalField(customField.getName()));
|
||||
} else {
|
||||
optionDTO.setName(customField.getName());
|
||||
|
|
|
@ -53,4 +53,7 @@ public class TemplateCustomFieldDTO {
|
|||
|
||||
@Schema(description = "是否平台系统字段")
|
||||
private Boolean platformSystemField;
|
||||
|
||||
@Schema(description = "内置字段的 key")
|
||||
private String internalFieldKey;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Arrays;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.metersphere.system.controller.handler.result.CommonResultCode.*;
|
||||
|
@ -105,12 +106,7 @@ public class BaseTemplateService {
|
|||
List<CustomField> customFields = baseCustomFieldService.getByIds(fieldIds);
|
||||
Map<String, CustomField> fieldMap = customFields
|
||||
.stream()
|
||||
.collect(Collectors.toMap(CustomField::getId, customField -> {
|
||||
if (customField.getInternal()) {
|
||||
customField.setName(baseCustomFieldService.translateInternalField(customField.getName()));
|
||||
}
|
||||
return customField;
|
||||
}));
|
||||
.collect(Collectors.toMap(CustomField::getId, Function.identity()));
|
||||
|
||||
// 封装自定义字段信息
|
||||
List<TemplateCustomFieldDTO> fieldDTOS = templateCustomFields.stream()
|
||||
|
@ -121,6 +117,10 @@ public class BaseTemplateService {
|
|||
TemplateCustomFieldDTO templateCustomFieldDTO = new TemplateCustomFieldDTO();
|
||||
BeanUtils.copyBean(templateCustomFieldDTO, i);
|
||||
templateCustomFieldDTO.setFieldName(customField.getName());
|
||||
if (BooleanUtils.isTrue(customField.getInternal())) {
|
||||
templateCustomFieldDTO.setInternalFieldKey(customField.getName());
|
||||
templateCustomFieldDTO.setFieldName(baseCustomFieldService.translateInternalField(customField.getName()));
|
||||
}
|
||||
templateCustomFieldDTO.setType(customField.getType());
|
||||
templateCustomFieldDTO.setInternal(customField.getInternal());
|
||||
AbstractCustomFieldResolver customFieldResolver = CustomFieldResolverFactory.getResolver(customField.getType());
|
||||
|
|
Loading…
Reference in New Issue