feat: JsonInclude.Include.NON_EMPTY 적용

dev
gitea-관리자 1 year ago
parent c62db6a6a7
commit 90c77d40a4

@ -77,7 +77,7 @@ spring:
data-source-properties: data-source-properties:
rewriteBatchedStatements: true rewriteBatchedStatements: true
# @JsonInclude(JsonInclude.Include.NON_NULL) 설정 # @JsonInclude(JsonInclude.Include.NON_EMPTY) 설정
jackson: jackson:
default-property-inclusion=non_null: non_null default-property-inclusion=non_null: non_null

@ -77,7 +77,7 @@ spring:
data-source-properties: data-source-properties:
rewriteBatchedStatements: true rewriteBatchedStatements: true
# @JsonInclude(JsonInclude.Include.NON_NULL) 설정 # @JsonInclude(JsonInclude.Include.NON_EMPTY) 설정
jackson: jackson:
default-property-inclusion=non_null: non_null default-property-inclusion=non_null: non_null

@ -92,8 +92,8 @@ ex) app:
@ Class Property 대소문자 @ Class Property 대소문자
Swagger API 사용시 대문자 필드 사용 불가 Swagger API 사용시 대문자 필드 사용 불가
대문자 필드 사용시 @Schema 속성 및 데이타 전달 불가 대문자 필드 사용시 @Schema 속성 및 데이타 전달 불가
@JsonProperty 또는 전체 클래스 필드인 경우 @JsonNaming 사용 @JsonProperty 또는 전체 클래스 필드인 경우 @JsonNaming 사용
json <-> java class 변환 적용 가능 json <-> java class 변환 적용
```text ```text
@JsonNaming(value = PropertyNamingStrategies.UpperSnakeCaseStrategy.class) @JsonNaming(value = PropertyNamingStrategies.UpperSnakeCaseStrategy.class)
public static class RequestDataHeader { public static class RequestDataHeader {
@ -141,3 +141,32 @@ json <-> java class 변환 적용 가능
-> getReqDtim -> getReqDtim
*/ */
``` ```
## Json 데이타 null 필드 제외
@JsonInclude(JsonInclude.Include.NON_EMPTY)
```text
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class)
public static class RequestDataHeader {
/**
* <pre>
* TRAN_ID : 요청한값 그대로 return
* 고유번호 : 최대 24
* </pre>
*/
@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 필드 제외
*/
```

@ -33,7 +33,7 @@ public class CmmEnsFileDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class FmcExcelUpload { public static class FmcExcelUpload {
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
@ -95,7 +95,7 @@ public class CmmEnsFileDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class FmcExcel { public static class FmcExcel {
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------

@ -36,7 +36,7 @@ public class KkopayDocAttrDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class Send implements IApiResponse { public static class Send implements IApiResponse {
/** /**
* : * :
@ -91,7 +91,7 @@ public class KkopayDocAttrDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class Receiver { public static class Receiver {
/** /**
* CI * CI
@ -137,7 +137,7 @@ public class KkopayDocAttrDTO {
@Data @Data
@SuperBuilder @SuperBuilder
@NoArgsConstructor @NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class Property { public static class Property {
/** /**
* : * :
@ -185,7 +185,7 @@ public class KkopayDocAttrDTO {
@SuperBuilder @SuperBuilder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class DocumentBinderUuid implements IApiResponse { public static class DocumentBinderUuid implements IApiResponse {
/** /**
* (max:40) - * (max:40) -
@ -200,7 +200,7 @@ public class KkopayDocAttrDTO {
@SuperBuilder @SuperBuilder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class DocStatus implements IApiResponse { public static class DocStatus implements IApiResponse {
/** /**
* <pre> * <pre>

@ -85,7 +85,7 @@ public class KkopayDocBulkDTO extends KkopayDocAttrDTO {
@SuperBuilder @SuperBuilder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class BulkSendRes { public static class BulkSendRes {
/** /**
* ()(max=40) - * ()(max=40) -
@ -148,7 +148,7 @@ public class KkopayDocBulkDTO extends KkopayDocAttrDTO {
@SuperBuilder @SuperBuilder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class BulkStatus { public static class BulkStatus {
/** /**
* (max:40) - * (max:40) -

@ -106,7 +106,7 @@ public class KkopayDocDTO extends KkopayDocAttrDTO {
@SuperBuilder @SuperBuilder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class ValidTokenResponse implements IApiResponse { public static class ValidTokenResponse implements IApiResponse {
/** /**
* ( USED) : * ( USED) :
@ -192,7 +192,7 @@ public class KkopayDocDTO extends KkopayDocAttrDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ToString @ToString
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class OneTimeToken extends ValidTokenRequest { public static class OneTimeToken extends ValidTokenRequest {
/** /**

@ -1,6 +1,7 @@
package kr.xit.biz.ens.model.nice; package kr.xit.biz.ens.model.nice;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.PropertyNamingStrategy;
@ -52,7 +53,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Builder @Builder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public static class TokenRequest { public static class TokenRequest {
/** /**
@ -84,7 +85,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class TokenResponse implements IApiResponse { public static class TokenResponse implements IApiResponse {
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(requiredMode = RequiredMode.REQUIRED)
@Valid @Valid
@ -105,7 +106,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class TokenRevokeResponse implements IApiResponse { public static class TokenRevokeResponse implements IApiResponse {
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(requiredMode = RequiredMode.REQUIRED)
@ -124,7 +125,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public static class TokenResDataBody { public static class TokenResDataBody {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@ -189,7 +190,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class PublickeyRequest { public static class PublickeyRequest {
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(requiredMode = RequiredMode.REQUIRED)
@Valid @Valid
@ -210,7 +211,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class PublickeyResponse implements IApiResponse { public static class PublickeyResponse implements IApiResponse {
@Schema(requiredMode = RequiredMode.REQUIRED) @Schema(requiredMode = RequiredMode.REQUIRED)
@Valid @Valid
@ -232,7 +233,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public static class PublickeyReqDataBody { public static class PublickeyReqDataBody {
/** /**
@ -254,7 +255,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public static class PublickeyResDataBody { public static class PublickeyResDataBody {
/** /**
@ -342,7 +343,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class) @JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class)
public static class RequestDataHeader { public static class RequestDataHeader {
@ -376,7 +377,7 @@ public class NiceCiDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class) @JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class)
public static class ResponseDataHeader { public static class ResponseDataHeader {
/** /**

@ -31,7 +31,7 @@ public class JsonUtils {
public static String toJson(Object obj) { public static String toJson(Object obj) {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
// null 필드 제 // null 필드 제
mapper.setSerializationInclusion(Include.NON_NULL); mapper.setSerializationInclusion(Include.NON_EMPTY);
// No serializer found for class 에러 - private 필드 // No serializer found for class 에러 - private 필드
mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
// mapper.setSerializationInclusion(Include.NON_EMPTY); // mapper.setSerializationInclusion(Include.NON_EMPTY);

Loading…
Cancel
Save