feat: DTO @JsonNaming 적용 처리

적용후 { TRAN_ID : "" } <-> getTranId, {tran_id : "" } <-> getTranId 가능
dev
gitea-관리자 1 year ago
parent ba715b954d
commit c62db6a6a7

@ -90,13 +90,13 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl {
return TokenResponse.builder() return TokenResponse.builder()
.dataHeader(ResponseDataHeader.builder() .dataHeader(ResponseDataHeader.builder()
.gw_rslt_cd("1200") .gwRsltCd("1200")
.gw_rslt_cd("오류없음") .gwRsltMsg("오류없음")
.build()) .build())
.dataBody(TokenResDataBody.builder() .dataBody(TokenResDataBody.builder()
.access_token("ff5e27fe-8b5d-49db-ab1e-0ccf07de6ac1") .accessToken("ff5e27fe-8b5d-49db-ab1e-0ccf07de6ac1")
.token_type("bearer") .tokenType("bearer")
.expires_in(1.57698305E9) .expiresIn(1.57698305E9)
.scope("default") .scope("default")
.build()) .build())
.build(); .build();
@ -136,19 +136,19 @@ public class NiceCiDummyTestService extends EgovAbstractServiceImpl {
return PublickeyResponse.builder() return PublickeyResponse.builder()
.dataHeader(ResponseDataHeader.builder() .dataHeader(ResponseDataHeader.builder()
.gw_rslt_cd("1200") .gwRsltCd("1200")
.gw_rslt_msg("오류없음") .gwRsltMsg("오류없음")
.tran_id(reqDTO.getDataHeader().getTran_id()) .tranId(reqDTO.getDataHeader().getTranId())
.cnty_id(reqDTO.getDataHeader().getCnty_id()) .cntyId(reqDTO.getDataHeader().getCntyId())
.build()) .build())
.dataBody(PublickeyResDataBody.builder() .dataBody(PublickeyResDataBody.builder()
.rsp_cd("P000") .rspCd("P000")
.rsp_msg("") .rspMsg("")
.result_cd("000") .resultCd("000")
.site_code("AAAA==") .siteCode("AAAA==")
.key_version("20210121ca8c1612-2c2d-IPaa-aad1-xxxxxxxxxxxx") .keyVersion("20210121ca8c1612-2c2d-IPaa-aad1-xxxxxxxxxxxx")
.public_key("MIIBIjANBgkqhkiG9w0BAQEFAA.....JJxwIDAQAB...") .publicKey("MIIBIjANBgkqhkiG9w0BAQEFAA.....JJxwIDAQAB...")
.valid_dtim("20220121181550") .validDtim("20220121181550")
.build()) .build())
.build(); .build();
} }

@ -89,3 +89,55 @@ ex) app:
# 필요시 xit-init 모듈 AppInitHelper.init() method 재정의 # 필요시 xit-init 모듈 AppInitHelper.init() method 재정의
``` ```
@ Class Property 대소문자
Swagger API 사용시 대문자 필드 사용 불가
대문자 필드 사용시 @Schema 속성 및 데이타 전달 불가
@JsonProperty 또는 전체 클래스 필드인 경우 @JsonNaming 사용
json <-> java class 변환 적용 가능
```text
@JsonNaming(value = 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자를 넘을 수 없습니다.")
//@JsonProperty("TRAN_ID")
private String tran_id;
/**
* CNTY_ID : 요청한값 그대로 return
*/
@Schema(requiredMode = RequiredMode.AUTO, title = "CNTY_ID", example = "kr")
@Size(min = 0, max = 2, message = "CNTY_ID는 2자를 넘을 수 없습니다.")
//@JsonProperty("CNTY_ID")
private String cnty_id;
}
/*
{
"TRAN_ID": "20230906120000",
"CNTY_ID": "kr"
}
-> getTranId, getCntyId
*/
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public static class PublickeyReqDataBody {
/**
* 공개키 요청일시 (YYYYMMDDHH24MISS)
*/
@Schema(requiredMode = RequiredMode.REQUIRED, title = "공개키 요청일시", example = "2023090612122259")
@Size(min = 16, max = 16, message = "요청일시(req_dtim)는 필수 입니다(16자리)")
private String reqDtim;
}
/*
{
"req_dtim": "20230906120000",
}
-> getReqDtim
*/
```

@ -2,6 +2,7 @@ package kr.xit.biz.ens.model.nice;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
@ -43,6 +44,7 @@ public class NiceCiDTO {
/** /**
* <pre> * <pre>
* Token(50 ) * Token(50 )
* Json data : SNAKE_CASE (grant_type <-> grantType)
* </pre> * </pre>
*/ */
@Schema(name = "TokenRequest", description = "기관용 Token(50년 유효) 발급 요청 파라메터 DTO") @Schema(name = "TokenRequest", description = "기관용 Token(50년 유효) 발급 요청 파라메터 DTO")
@ -51,6 +53,7 @@ public class NiceCiDTO {
@AllArgsConstructor @AllArgsConstructor
@Builder @Builder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public static class TokenRequest { public static class TokenRequest {
/** /**
* default * default
@ -66,7 +69,7 @@ public class NiceCiDTO {
@Default @Default
@Schema(requiredMode = RequiredMode.REQUIRED, title = "grant_type", example = "clinet_credentials") @Schema(requiredMode = RequiredMode.REQUIRED, title = "grant_type", example = "clinet_credentials")
@Size(min = 1, message = "grant_type은 필수입니다") @Size(min = 1, message = "grant_type은 필수입니다")
private String grant_type = "clinet_credentials"; private String grantType = "clinet_credentials";
} }
/** /**
@ -111,7 +114,10 @@ public class NiceCiDTO {
} }
/** /**
* <pre>
* dataBody * dataBody
* Json data : SNAKE_CASE (access_token <-> accessToken)
* </pre>
*/ */
@Schema(name = "TokenResDataBody", description = "기관용 토큰 발급 요청 응답 dataBody DTO") @Schema(name = "TokenResDataBody", description = "기관용 토큰 발급 요청 응답 dataBody DTO")
@Data @Data
@ -119,6 +125,7 @@ public class NiceCiDTO {
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public static class TokenResDataBody { public static class TokenResDataBody {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// 토근 발급 요청시 필수값 // 토근 발급 요청시 필수값
@ -130,20 +137,20 @@ public class NiceCiDTO {
* </pre> * </pre>
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "사용자 엑세스 토큰 값", example = " ") @Schema(requiredMode = RequiredMode.AUTO, title = "사용자 엑세스 토큰 값", example = " ")
private String access_token; private String accessToken;
/** /**
* token_type : token * token_type : token
* bearer * bearer
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "token_type", example = "bearer") @Schema(requiredMode = RequiredMode.AUTO, title = "token_type", example = "bearer")
private String token_type; private String tokenType;
/** /**
* access () : token * access () : token
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "access 토큰 만료 시간(초)", example = "1.57698305E9") @Schema(requiredMode = RequiredMode.AUTO, title = "access 토큰 만료 시간(초)", example = "1.57698305E9")
private double expires_in; private double expiresIn;
/** /**
* <pre> * <pre>
@ -215,7 +222,10 @@ public class NiceCiDTO {
} }
/** /**
* Request dataHeader * <pre>
* dataBody DTO
* Json data : SNAKE_CASE (req_dtim <-> reqDtim)
* </pre>
*/ */
@Schema(name = "PublickeyReqDataBody", description = "공개키 요청 dataBody DTO") @Schema(name = "PublickeyReqDataBody", description = "공개키 요청 dataBody DTO")
@Data @Data
@ -223,27 +233,35 @@ public class NiceCiDTO {
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public static class PublickeyReqDataBody { public static class PublickeyReqDataBody {
/** /**
* (YYYYMMDDHH24MISS) * (YYYYMMDDHH24MISS)
*/ */
@Schema(requiredMode = RequiredMode.REQUIRED, title = "공개키 요청일시", example = "2023090612122259") @Schema(requiredMode = RequiredMode.REQUIRED, title = "공개키 요청일시", example = "2023090612122259")
@Size(min = 16, max = 16, message = "요청일시(req_dtim)는 필수 입니다(16자리)") @Size(min = 16, max = 16, message = "요청일시(req_dtim)는 필수 입니다(16자리)")
private String req_dtim; private String reqDtim;
} }
/**
* <pre>
* dataBody DTO
* Json data : SNAKE_CASE (rsp_cd <-> rspCd)
* </pre>
*/
@Schema(name = "PublickeyResDataBody", description = "공개키 요청 응답 dataBody DTO") @Schema(name = "PublickeyResDataBody", description = "공개키 요청 응답 dataBody DTO")
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public static class PublickeyResDataBody { public static class PublickeyResDataBody {
/** /**
* dataBody (P000 , ) : 8 * dataBody (P000 , ) : 8
*/ */
@Schema(requiredMode = RequiredMode.REQUIRED, title = "정상처리 여부", example = "P000") @Schema(requiredMode = RequiredMode.REQUIRED, title = "정상처리 여부", example = "P000")
private String rsp_cd; private String rspCd;
/** /**
* <pre> * <pre>
@ -252,7 +270,7 @@ public class NiceCiDTO {
* </pre> * </pre>
*/ */
@Schema(requiredMode = RequiredMode.REQUIRED, title = "상세 메세지", example = " ") @Schema(requiredMode = RequiredMode.REQUIRED, title = "상세 메세지", example = " ")
private String rsp_msg; private String rspMsg;
/** /**
* <pre> * <pre>
@ -264,7 +282,7 @@ public class NiceCiDTO {
* </pre> * </pre>
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "상세 결과코드", example = "0000") @Schema(requiredMode = RequiredMode.AUTO, title = "상세 결과코드", example = "0000")
private String result_cd; private String resultCd;
/** /**
* <pre> * <pre>
@ -272,7 +290,7 @@ public class NiceCiDTO {
* </pre> * </pre>
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "사이트 코드", example = " ") @Schema(requiredMode = RequiredMode.AUTO, title = "사이트 코드", example = " ")
private String site_code; private String siteCode;
/** /**
* <pre> * <pre>
@ -280,7 +298,7 @@ public class NiceCiDTO {
* </pre> * </pre>
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "공개키 버전", example = " ") @Schema(requiredMode = RequiredMode.AUTO, title = "공개키 버전", example = " ")
private String key_version; private String keyVersion;
/** /**
* <pre> * <pre>
@ -288,7 +306,7 @@ public class NiceCiDTO {
* </pre> * </pre>
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "공개키", example = " ") @Schema(requiredMode = RequiredMode.AUTO, title = "공개키", example = " ")
private String public_key; private String publicKey;
/** /**
* <pre> * <pre>
@ -296,7 +314,7 @@ public class NiceCiDTO {
* </pre> * </pre>
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "공개키 만료일시", example = " ") @Schema(requiredMode = RequiredMode.AUTO, title = "공개키 만료일시", example = " ")
private String valid_dtim; private String validDtim;
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// 공개키 : publickey // 공개키 : publickey
@ -314,7 +332,10 @@ public class NiceCiDTO {
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/** /**
* <pre>
* Request dataHeader * Request dataHeader
* Json data : UPPER_SNAKE_CASE (GW_RSLT_CD <-> gwRsltCd)
* </pre>
*/ */
@Schema(name = "RequestDataHeader", description = "Nice CI request dataHeader(공통)") @Schema(name = "RequestDataHeader", description = "Nice CI request dataHeader(공통)")
@Data @Data
@ -322,6 +343,7 @@ public class NiceCiDTO {
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class)
public static class RequestDataHeader { public static class RequestDataHeader {
/** /**
@ -332,21 +354,22 @@ public class NiceCiDTO {
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "TRAN_ID", example = "20230906120000") @Schema(requiredMode = RequiredMode.AUTO, title = "TRAN_ID", example = "20230906120000")
@Size(min = 0, max = 24, message = "TRAN_ID는 24자를 넘을 수 없습니다.") @Size(min = 0, max = 24, message = "TRAN_ID는 24자를 넘을 수 없습니다.")
@JsonProperty("TRAN_ID") private String tranId;
private String tran_id;
/** /**
* CNTY_ID : return * CNTY_ID : return
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "CNTY_ID", example = "kr") @Schema(requiredMode = RequiredMode.AUTO, title = "CNTY_ID", example = "kr")
@Size(min = 0, max = 2, message = "CNTY_ID는 2자를 넘을 수 없습니다.") @Size(min = 0, max = 2, message = "CNTY_ID는 2자를 넘을 수 없습니다.")
@JsonProperty("CNTY_ID") private String cntyId;
private String cnty_id;
} }
/** /**
* <pre>
* Response dataHeader * Response dataHeader
* Json data : UPPER_SNAKE_CASE (GW_RSLT_CD <-> gwRsltCd)
* </pre>
*/ */
@Schema(name = "ResponseDataHeader", description = "Nice CI Response dataHeader(공통)") @Schema(name = "ResponseDataHeader", description = "Nice CI Response dataHeader(공통)")
@Data @Data
@ -354,6 +377,7 @@ public class NiceCiDTO {
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class)
public static class ResponseDataHeader { public static class ResponseDataHeader {
/** /**
* <pre> * <pre>
@ -363,16 +387,14 @@ public class NiceCiDTO {
*/ */
@Schema(requiredMode = RequiredMode.REQUIRED, title = "응답코드", example = "1200") @Schema(requiredMode = RequiredMode.REQUIRED, title = "응답코드", example = "1200")
@Size(min = 1, max = 8) @Size(min = 1, max = 8)
@JsonProperty("GW_RSLT_CD") private String gwRsltCd;
private String gw_rslt_cd;
/** /**
* : 200 * : 200
*/ */
@Schema(requiredMode = RequiredMode.REQUIRED, title = "응답메세지", example = "오류없음") @Schema(requiredMode = RequiredMode.REQUIRED, title = "응답메세지", example = "오류없음")
@Size(min = 1, max = 200) @Size(min = 1, max = 200)
@JsonProperty("GW_RSLT_MSG") private String gwRsltMsg;
private String gw_rslt_msg;
/** /**
* <pre> * <pre>
@ -381,8 +403,7 @@ public class NiceCiDTO {
* </pre> * </pre>
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "TRAN_ID", example = " ") @Schema(requiredMode = RequiredMode.AUTO, title = "TRAN_ID", example = " ")
@JsonProperty("TRAN_ID") private String tranId;
private String tran_id;
/** /**
* <pre> * <pre>
@ -391,8 +412,7 @@ public class NiceCiDTO {
* </pre> * </pre>
*/ */
@Schema(requiredMode = RequiredMode.AUTO, title = "CNTY_ID", example = " ") @Schema(requiredMode = RequiredMode.AUTO, title = "CNTY_ID", example = " ")
@JsonProperty("CNTY_ID") private String cntyId;
private String cnty_id;
} }

Loading…
Cancel
Save