diff --git a/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/api/materialinfomation/dto/MaterialInfomationRespDTO.java b/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/api/materialinfomation/dto/MaterialInfomationRespDTO.java index eeb1ba5d..c92a8207 100644 --- a/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/api/materialinfomation/dto/MaterialInfomationRespDTO.java +++ b/zt-module-base/zt-module-base-api/src/main/java/com/zt/plat/module/base/api/materialinfomation/dto/MaterialInfomationRespDTO.java @@ -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 flatAttributes; + @Schema(description = "物料基础字段 + 属性编码->原值的动态键值") + private Map flatAttributes = new LinkedHashMap<>(); @JsonAnyGetter public Map getFlatAttributes() { return flatAttributes; } + + @JsonAnySetter + public void addAttribute(String key, Object value) { + if (flatAttributes == null) { + flatAttributes = new LinkedHashMap<>(); + } + flatAttributes.put(key, value); + } } \ No newline at end of file