From c5da270de155e5d29ea078b6c443a8484fdbf3e8 Mon Sep 17 00:00:00 2001 From: wuzongyong <13203449218@163.com> Date: Thu, 8 Jan 2026 17:23:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(material):=20=E6=9B=B4=E6=96=B0=E7=89=A9?= =?UTF-8?q?=E6=96=99=E4=BF=A1=E6=81=AF=E5=93=8D=E5=BA=94DTO=E7=9A=84JSON?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8C=96=E9=85=8D=E7=BD=AE=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E9=97=AE=E9=A2=98=E4=BD=BF=E7=94=A8id=E8=B0=83?= =?UTF-8?q?=E7=94=A8feign=E6=8E=A5=E5=8F=A3=E6=9F=A5=E8=AF=A2=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=B8=BAnull=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1id690?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为ID、编码、名称、分类ID、备注和创建时间字段添加JsonProperty注解 - 将flatAttributes字段初始化为LinkedHashMap以保证顺序 - 添加JsonAnySetter注解和addAttribute方法处理动态属性 - 移除原flatAttributes字段的序列化展开说明 --- .../dto/MaterialInfomationRespDTO.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) 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