From 90c77d40a400e96a50581ce7272a8121c691fc97 Mon Sep 17 00:00:00 2001 From: limju Date: Mon, 11 Sep 2023 10:36:34 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20JsonInclude.Include.NON=5FEMPTY=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/config/application.yml | 2 +- .../src/main/resources/config/application.yml | 2 +- mens-core/README.md | 33 +++++++++++++++++-- .../xit/biz/ens/model/cmm/CmmEnsFileDTO.java | 4 +-- .../biz/ens/model/kakao/KkopayDocAttrDTO.java | 10 +++--- .../biz/ens/model/kakao/KkopayDocBulkDTO.java | 4 +-- .../xit/biz/ens/model/kakao/KkopayDocDTO.java | 4 +-- .../kr/xit/biz/ens/model/nice/NiceCiDTO.java | 21 ++++++------ .../kr/xit/core/support/utils/JsonUtils.java | 2 +- 9 files changed, 56 insertions(+), 26 deletions(-) diff --git a/mens-api/src/main/resources/config/application.yml b/mens-api/src/main/resources/config/application.yml index b1273ac..7072751 100644 --- a/mens-api/src/main/resources/config/application.yml +++ b/mens-api/src/main/resources/config/application.yml @@ -77,7 +77,7 @@ spring: data-source-properties: rewriteBatchedStatements: true - # @JsonInclude(JsonInclude.Include.NON_NULL) 설정 + # @JsonInclude(JsonInclude.Include.NON_EMPTY) 설정 jackson: default-property-inclusion=non_null: non_null diff --git a/mens-batch/src/main/resources/config/application.yml b/mens-batch/src/main/resources/config/application.yml index 3ce79b8..30b9ef6 100644 --- a/mens-batch/src/main/resources/config/application.yml +++ b/mens-batch/src/main/resources/config/application.yml @@ -77,7 +77,7 @@ spring: data-source-properties: rewriteBatchedStatements: true - # @JsonInclude(JsonInclude.Include.NON_NULL) 설정 + # @JsonInclude(JsonInclude.Include.NON_EMPTY) 설정 jackson: default-property-inclusion=non_null: non_null diff --git a/mens-core/README.md b/mens-core/README.md index eba0d5e..c69030b 100644 --- a/mens-core/README.md +++ b/mens-core/README.md @@ -92,8 +92,8 @@ ex) app: @ Class Property 대소문자 Swagger API 사용시 대문자 필드 사용 불가 대문자 필드 사용시 @Schema 속성 및 데이타 전달 불가 -@JsonProperty 또는 전체 클래스 필드인 경우 @JsonNaming 사용 -json <-> java class 변환 적용 가능 +@JsonProperty 또는 전체 클래스 필드인 경우 @JsonNaming 사용 +json <-> java class 변환 적용 ```text @JsonNaming(value = PropertyNamingStrategies.UpperSnakeCaseStrategy.class) public static class RequestDataHeader { @@ -141,3 +141,32 @@ json <-> java class 변환 적용 가능 -> getReqDtim */ ``` +## Json 데이타 null 필드 제외 +@JsonInclude(JsonInclude.Include.NON_EMPTY) +```text + @JsonInclude(JsonInclude.Include.NON_EMPTY) + @JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class) + public static class RequestDataHeader { + + /** + *
+         * TRAN_ID : 요청한값 그대로 return
+         * 고유번호 : 최대 24
+         * 
+ */ + @Schema(requiredMode = RequiredMode.AUTO, title = "TRAN_ID", example = "20230906120000") + @Size(min = 0, max = 24, message = "TRAN_ID는 24자를 넘을 수 없습니다.") + private String tranId; + + /** + * CNTY_ID : 요청한값 그대로 return + */ + @Schema(requiredMode = RequiredMode.AUTO, title = "CNTY_ID", example = "kr") + @Size(min = 0, max = 2, message = "CNTY_ID는 2자를 넘을 수 없습니다.") + private String cntyId; + } + + /* + {TRAN_ID : null or ""} --> tranId 필드 제외 + */ +``` diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsFileDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsFileDTO.java index 8e8656f..c1b0cc3 100644 --- a/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsFileDTO.java +++ b/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsFileDTO.java @@ -33,7 +33,7 @@ public class CmmEnsFileDTO { @NoArgsConstructor @AllArgsConstructor @SuperBuilder - @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonInclude(JsonInclude.Include.NON_EMPTY) public static class FmcExcelUpload { //----------------------------------------------------------------------------------- @@ -95,7 +95,7 @@ public class CmmEnsFileDTO { @NoArgsConstructor @AllArgsConstructor @SuperBuilder - @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonInclude(JsonInclude.Include.NON_EMPTY) public static class FmcExcel { //----------------------------------------------------------------------------------- diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocAttrDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocAttrDTO.java index 0cb4f61..33532c6 100644 --- a/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocAttrDTO.java +++ b/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocAttrDTO.java @@ -36,7 +36,7 @@ public class KkopayDocAttrDTO { @NoArgsConstructor @AllArgsConstructor @SuperBuilder - @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonInclude(JsonInclude.Include.NON_EMPTY) public static class Send implements IApiResponse { /** * 발송할 문서의 제목 : 필수 @@ -91,7 +91,7 @@ public class KkopayDocAttrDTO { @NoArgsConstructor @AllArgsConstructor @SuperBuilder - @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonInclude(JsonInclude.Include.NON_EMPTY) public static class Receiver { /** * 받는이 CI @@ -137,7 +137,7 @@ public class KkopayDocAttrDTO { @Data @SuperBuilder @NoArgsConstructor - @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonInclude(JsonInclude.Include.NON_EMPTY) public static class Property { /** * 본인인증 후 사용자에게 보여줄 웹페이지 주소 : 필수 @@ -185,7 +185,7 @@ public class KkopayDocAttrDTO { @SuperBuilder @NoArgsConstructor @AllArgsConstructor - @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonInclude(JsonInclude.Include.NON_EMPTY) public static class DocumentBinderUuid implements IApiResponse { /** * 카카오페이 문서식별번호(max:40) - 필수 @@ -200,7 +200,7 @@ public class KkopayDocAttrDTO { @SuperBuilder @NoArgsConstructor @AllArgsConstructor - @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonInclude(JsonInclude.Include.NON_EMPTY) public static class DocStatus implements IApiResponse { /** *
diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocBulkDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocBulkDTO.java
index 80271b4..33979f1 100644
--- a/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocBulkDTO.java
+++ b/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocBulkDTO.java
@@ -85,7 +85,7 @@ public class KkopayDocBulkDTO extends KkopayDocAttrDTO {
     @SuperBuilder
     @NoArgsConstructor
     @AllArgsConstructor
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     public static class BulkSendRes {
         /**
          * 문서 아이디(외부)(max=40) - 필수
@@ -148,7 +148,7 @@ public class KkopayDocBulkDTO extends KkopayDocAttrDTO {
     @SuperBuilder
     @NoArgsConstructor
     @AllArgsConstructor
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     public static class BulkStatus {
         /**
          * 카카오페이 문서식별 번호(max:40) - 필수
diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocDTO.java
index 1c6eaed..0181e0a 100644
--- a/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocDTO.java
+++ b/mens-core/src/main/java/kr/xit/biz/ens/model/kakao/KkopayDocDTO.java
@@ -106,7 +106,7 @@ public class KkopayDocDTO extends KkopayDocAttrDTO {
     @SuperBuilder
     @NoArgsConstructor
     @AllArgsConstructor
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     public static class ValidTokenResponse implements IApiResponse {
         /**
          * 토큰상태값(성공시 USED) : 필수
@@ -192,7 +192,7 @@ public class KkopayDocDTO extends KkopayDocAttrDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @ToString
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     @EqualsAndHashCode(callSuper = true)
     public static class OneTimeToken extends ValidTokenRequest {
         /**
diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/nice/NiceCiDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/nice/NiceCiDTO.java
index a839049..d46109f 100644
--- a/mens-core/src/main/java/kr/xit/biz/ens/model/nice/NiceCiDTO.java
+++ b/mens-core/src/main/java/kr/xit/biz/ens/model/nice/NiceCiDTO.java
@@ -1,6 +1,7 @@
 package kr.xit.biz.ens.model.nice;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.databind.PropertyNamingStrategies;
 import com.fasterxml.jackson.databind.PropertyNamingStrategy;
@@ -52,7 +53,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @Builder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
     public static class TokenRequest {
         /**
@@ -84,7 +85,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @SuperBuilder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     public static class TokenResponse implements IApiResponse {
         @Schema(requiredMode = RequiredMode.REQUIRED)
         @Valid
@@ -105,7 +106,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @SuperBuilder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     public static class TokenRevokeResponse implements IApiResponse {
 
         @Schema(requiredMode = RequiredMode.REQUIRED)
@@ -124,7 +125,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @SuperBuilder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
     public static class TokenResDataBody {
         //-----------------------------------------------------------------------
@@ -189,7 +190,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @SuperBuilder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     public static class PublickeyRequest {
         @Schema(requiredMode = RequiredMode.REQUIRED)
         @Valid
@@ -210,7 +211,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @SuperBuilder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     public static class PublickeyResponse implements IApiResponse {
         @Schema(requiredMode = RequiredMode.REQUIRED)
         @Valid
@@ -232,7 +233,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @SuperBuilder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
     public static class PublickeyReqDataBody {
         /**
@@ -254,7 +255,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @SuperBuilder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(Include.NON_EMPTY)
     @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
     public static class PublickeyResDataBody {
         /**
@@ -342,7 +343,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @SuperBuilder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     @JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class)
     public static class RequestDataHeader {
 
@@ -376,7 +377,7 @@ public class NiceCiDTO {
     @NoArgsConstructor
     @AllArgsConstructor
     @SuperBuilder
-    @JsonInclude(JsonInclude.Include.NON_NULL)
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
     @JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class)
     public static class ResponseDataHeader {
         /**
diff --git a/mens-core/src/main/java/kr/xit/core/support/utils/JsonUtils.java b/mens-core/src/main/java/kr/xit/core/support/utils/JsonUtils.java
index c104645..d78215e 100644
--- a/mens-core/src/main/java/kr/xit/core/support/utils/JsonUtils.java
+++ b/mens-core/src/main/java/kr/xit/core/support/utils/JsonUtils.java
@@ -31,7 +31,7 @@ public class JsonUtils {
 	public static String toJson(Object obj) {
 		ObjectMapper mapper = new ObjectMapper();
 		// null 필드 제
-		mapper.setSerializationInclusion(Include.NON_NULL);
+		mapper.setSerializationInclusion(Include.NON_EMPTY);
 		// No serializer found for class 에러 - private 필드
 		mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
 //		mapper.setSerializationInclusion(Include.NON_EMPTY);