feat(material): 更新物料信息响应DTO的JSON序列化配置,解决问题使用id调用feign接口查询返回为null的问题,任务id690
- 为ID、编码、名称、分类ID、备注和创建时间字段添加JsonProperty注解 - 将flatAttributes字段初始化为LinkedHashMap以保证顺序 - 添加JsonAnySetter注解和addAttribute方法处理动态属性 - 移除原flatAttributes字段的序列化展开说明
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package com.zt.plat.module.base.api.materialinfomation.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -14,36 +17,44 @@ import java.util.Map;
|
||||
@Data
|
||||
public class MaterialInfomationRespDTO {
|
||||
|
||||
@JsonIgnore
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3326")
|
||||
private Long id;
|
||||
|
||||
@JsonIgnore
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
@Schema(description = "物料编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String code;
|
||||
|
||||
@JsonIgnore
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
@Schema(description = "物料名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
private String name;
|
||||
|
||||
@JsonIgnore
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
@Schema(description = "分类ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long classesId;
|
||||
|
||||
@JsonIgnore
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String remark;
|
||||
|
||||
@JsonIgnore
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@JsonIgnore
|
||||
@Schema(description = "物料基础字段 + 属性编码->原值的动态键值,基础字段优先,序列化时直接展开为顶层字段")
|
||||
private Map<String, Object> flatAttributes;
|
||||
@Schema(description = "物料基础字段 + 属性编码->原值的动态键值")
|
||||
private Map<String, Object> flatAttributes = new LinkedHashMap<>();
|
||||
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getFlatAttributes() {
|
||||
return flatAttributes;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
public void addAttribute(String key, Object value) {
|
||||
if (flatAttributes == null) {
|
||||
flatAttributes = new LinkedHashMap<>();
|
||||
}
|
||||
flatAttributes.put(key, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user