Commit 74c131c9 by 叶立庆

增加任务业务描述信息中图片和附件的列表对象字段定义

1 parent 06a08222
......@@ -30,9 +30,9 @@ public class TaskBizDisplayFieldDTO implements Serializable {
@ApiModelProperty(notes = "字段类型")
private String fieldType;
/** 字段值。 */
@ApiModelProperty(notes = "字段值")
private String fieldValue;
/** 字段值(字符串或列表)。 */
@ApiModelProperty(notes = "字段值(字符串或列表)")
private Object fieldValue;
/** 链接别名。 */
@ApiModelProperty(notes = "链接别名")
......
package cn.com.glsx.dj.taskcenter.dto.taskcenter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.Data;
/**
* 任务业务展示列表项 DTO。
*
* <p>用于表示图片或附件类型的字段值列表项。
* <p>作者:SOLO
* <p>创建时间:2026-05-20
*/
@Data
@ApiModel(value = "TaskBizDisplayItemDTO", description = "任务业务展示列表项")
public class TaskBizDisplayItemDTO implements Serializable {
private static final long serialVersionUID = 1L;
/** 字段名。 */
@ApiModelProperty(notes = "字段名")
private String name;
/** 字段值(图片链接或文件链接)。 */
@ApiModelProperty(notes = "字段值(图片链接或文件链接)")
private String value;
}
......@@ -6,6 +6,7 @@ import cn.com.glsx.dj.taskcenter.dto.taskcenter.TaskAssigneeDTO;
import cn.com.glsx.dj.taskcenter.dto.taskcenter.TaskAssigneeInputDTO;
import cn.com.glsx.dj.taskcenter.dto.taskcenter.TaskBizCategoryDTO;
import cn.com.glsx.dj.taskcenter.dto.taskcenter.TaskBizDisplayFieldDTO;
import cn.com.glsx.dj.taskcenter.dto.taskcenter.TaskBizDisplayItemDTO;
import cn.com.glsx.dj.taskcenter.dto.taskcenter.TaskDTO;
import cn.com.glsx.dj.taskcenter.dto.taskcenter.TaskQueryConditionDTO;
import cn.com.glsx.dj.taskcenter.enums.TaskBizDisplayFieldTypeEnum;
......@@ -759,47 +760,93 @@ public class TaskCenterService {
if (fieldTypeEnum == null) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldType[%s]不合法", i + 1, fieldDTO.getFieldType()));
}
if (StringUtils.isBlank(fieldDTO.getFieldValue())) {
if (fieldDTO.getFieldValue() == null) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue不能为空", i + 1));
}
validateFieldValue(fieldTypeEnum, fieldDTO.getFieldValue(), i);
}
}
private void validateFieldValue(TaskBizDisplayFieldTypeEnum fieldType, String fieldValue, int index) {
private void validateFieldValue(TaskBizDisplayFieldTypeEnum fieldType, Object fieldValue, int index) {
switch (fieldType) {
case TEXT:
case ENUM:
case LINK:
case IMAGE:
case ATTACHMENT:
if (!(fieldValue instanceof String)) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue必须是字符串", index + 1));
}
if (StringUtils.isBlank((String) fieldValue)) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue不能为空", index + 1));
}
break;
case NUMBER:
String numStr;
if (fieldValue instanceof Number) {
numStr = fieldValue.toString();
} else if (fieldValue instanceof String) {
numStr = (String) fieldValue;
} else {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue必须是数值", index + 1));
}
try {
new java.math.BigDecimal(fieldValue);
new java.math.BigDecimal(numStr);
} catch (NumberFormatException e) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue[%s]不是有效的数值", index + 1, fieldValue));
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue[%s]不是有效的数值", index + 1, numStr));
}
break;
case DATETIME:
String dateStr;
if (fieldValue instanceof String) {
dateStr = (String) fieldValue;
} else {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue必须是日期时间字符串", index + 1));
}
try {
java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(fieldValue);
java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(dateStr);
} catch (Exception e1) {
try {
java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").parse(fieldValue);
java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").parse(dateStr);
} catch (Exception e2) {
try {
java.time.format.DateTimeFormatter.ISO_LOCAL_DATE.parse(fieldValue);
java.time.format.DateTimeFormatter.ISO_LOCAL_DATE.parse(dateStr);
} catch (Exception e3) {
try {
java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd").parse(fieldValue);
java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd").parse(dateStr);
} catch (Exception e4) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue[%s]不是有效的日期时间格式", index + 1, fieldValue));
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue[%s]不是有效的日期时间格式", index + 1, dateStr));
}
}
}
}
break;
case IMAGE:
case ATTACHMENT:
if (!(fieldValue instanceof List)) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue必须是列表", index + 1));
}
List<?> itemList = (List<?>) fieldValue;
if (itemList.isEmpty()) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项fieldValue列表不能为空", index + 1));
}
for (int j = 0; j < itemList.size(); j++) {
Object itemObj = itemList.get(j);
if (itemObj == null) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项第%d个列表项不能为空", index + 1, j + 1));
}
TaskBizDisplayItemDTO item;
try {
item = OBJECT_MAPPER.convertValue(itemObj, TaskBizDisplayItemDTO.class);
} catch (Exception e) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项第%d个列表项格式错误", index + 1, j + 1));
}
if (StringUtils.isBlank(item.getName())) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项第%d个列表项name不能为空", index + 1, j + 1));
}
if (StringUtils.isBlank(item.getValue())) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, String.format("bizDisplayInfo第%d项第%d个列表项value不能为空", index + 1, j + 1));
}
}
break;
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!