feat(REQ-3982) - 调整表单 value 的默认响应
This commit is contained in:
parent
b705b992e6
commit
a2ba80fbc1
@ -8,12 +8,13 @@ package cn.axzo.workflow.form.service.converter;
|
||||
*/
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConversionUtils {
|
||||
public static Object convertObjectToList(Object obj) {
|
||||
public static Object convertObject(Object obj) {
|
||||
if (obj instanceof List) {
|
||||
List<?> list = (List<?>) obj;
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
@ -28,9 +29,16 @@ public class ConversionUtils {
|
||||
}
|
||||
}
|
||||
return stringList;
|
||||
} else {
|
||||
} else if (obj instanceof String) {
|
||||
if (StringUtils.pathEquals(obj.toString(), "[]")) {
|
||||
return null;
|
||||
} else if (StringUtils.hasText(obj.toString())) {
|
||||
return ((String) obj).replace("[", "").replace("]", "");
|
||||
}
|
||||
// 如果输入不是列表类型,返回空列表或进行其他处理
|
||||
return obj;
|
||||
} else {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public interface FormFieldConverter extends EntityConverter<FormFieldDTO, FormFi
|
||||
@Mapping(target = "id", source = "entity.id")
|
||||
@Mapping(target = "name", source = "entity.name")
|
||||
@Mapping(target = "type", source = "entity.type")
|
||||
@Mapping(target = "value", expression = "java(ConversionUtils.convertObjectToList(entity.getValue()))")
|
||||
@Mapping(target = "value", expression = "java(ConversionUtils.convertObject(entity.getValue()))")
|
||||
@Mapping(target = "placeholder", source = "entity.placeholder")
|
||||
@Mapping(target = "params", source = "entity.params")
|
||||
FormFieldDTO toVo(FormField entity);
|
||||
@ -38,7 +38,7 @@ public interface FormFieldConverter extends EntityConverter<FormFieldDTO, FormFi
|
||||
@Mapping(target = "id", source = "entity.id")
|
||||
@Mapping(target = "name", source = "entity.name")
|
||||
@Mapping(target = "type", source = "entity.type")
|
||||
@Mapping(target = "value", expression = "java(ConversionUtils.convertObjectToList(entity.getValue()))")
|
||||
@Mapping(target = "value", expression = "java(ConversionUtils.convertObject(entity.getValue()))")
|
||||
@Mapping(target = "placeholder", source = "entity.placeholder")
|
||||
@Mapping(target = "params", source = "entity.params")
|
||||
@Mapping(target = "fields", source = "entity.fields")
|
||||
|
||||
@ -61,7 +61,7 @@ public interface FormInstanceConverter extends EntityConverter<FormInstanceVO, F
|
||||
formFieldDTO.setType(formField.getType());
|
||||
formFieldDTO.setId(formField.getId());
|
||||
formFieldDTO.setName(formField.getName());
|
||||
formFieldDTO.setValue(formField.getValue());
|
||||
formFieldDTO.setValue(ConversionUtils.convertObject(formField.getValue()));
|
||||
formFieldDTO.setPlaceholder(formField.getPlaceholder());
|
||||
formFieldDTO.setParams(formField.getParams());
|
||||
if (formField instanceof FormContainer) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user