feat: KAKAO API 부서별 처리 적용

dev
gitea-관리자 1 year ago
parent 2c176a87d4
commit 066750d2d1

@ -0,0 +1,46 @@
package kr.xit.ens.kakao.cmm;
import egovframework.com.cmm.EgovMessageSource;
import kr.xit.biz.cmm.service.ICmmEnsCacheService;
import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO;
import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.spring.util.ApiSpringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
/**
* <pre>
* description :
*
* packageName : kr.xit.ens.kakao.cmm
* fileName : CmmKakaoUtils
* author : limju
* date : 2023-09-19
* ======================================================================
*
* ----------------------------------------------------------------------
* 2023-09-19 limju
*
* </pre>
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CmmKakaoUtils {
private static final EgovMessageSource messageSource = ApiSpringUtils.getMessageSource();
private static final ICmmEnsCacheService cacheService = ApiSpringUtils.getCmmEnsCacheService();
/**
* KT MMS
* @return
*/
public static CmmEnsRlaybsnmDTO getRlaybsnmInfo(final String signguCode, final String ffnlgCode) {
final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(signguCode, ffnlgCode);
if(ObjectUtils.isEmpty(dto)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info"));
cacheService.logCache();
return dto;
}
}

@ -27,6 +27,7 @@ import kr.xit.core.spring.annotation.TraceLogging;
import kr.xit.core.spring.util.ApiWebClientUtil; import kr.xit.core.spring.util.ApiWebClientUtil;
import kr.xit.core.support.utils.Checks; import kr.xit.core.support.utils.Checks;
import kr.xit.core.support.utils.JsonUtils; import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.kakao.cmm.CmmKakaoUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
@ -108,7 +109,7 @@ public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implemen
if(Objects.requireNonNull(errors).size() > 0) throw BizRuntimeException.create(errors.toString()); if(Objects.requireNonNull(errors).size() > 0) throw BizRuntimeException.create(errors.toString());
return CompletableFuture.supplyAsync(() -> return CompletableFuture.supplyAsync(() ->
webClient.exchangeKko(HOST + API_SEND[0], HttpMethod.valueOf(API_SEND[1]), JsonUtils.toJson(reqDTO), SendResponse.class)) webClient.exchangeKko(HOST + API_SEND[0], HttpMethod.valueOf(API_SEND[1]), JsonUtils.toJson(reqDTO), SendResponse.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())))
.handle((r, e) -> { .handle((r, e) -> {
if(e != null){ if(e != null){
return webClient.sendError(e); return webClient.sendError(e);
@ -135,7 +136,7 @@ public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implemen
.replace("{tokens}", reqDTO.getToken()); .replace("{tokens}", reqDTO.getToken());
return CompletableFuture.supplyAsync(() -> return CompletableFuture.supplyAsync(() ->
webClient.exchangeKko(url, HttpMethod.valueOf(API_VALID_TOKEN[1]), null, ValidTokenResponse.class)) webClient.exchangeKko(url, HttpMethod.valueOf(API_VALID_TOKEN[1]), null, ValidTokenResponse.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())))
.handle((r, e) -> { .handle((r, e) -> {
if(e != null){ if(e != null){
return webClient.sendError(e); return webClient.sendError(e);
@ -165,7 +166,7 @@ public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implemen
final String url = HOST + API_MODIFY_STATUS[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid()); final String url = HOST + API_MODIFY_STATUS[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid());
return CompletableFuture.supplyAsync(() -> return CompletableFuture.supplyAsync(() ->
webClient.exchangeKko(url, HttpMethod.valueOf(API_MODIFY_STATUS[1]), body, Void.class)) webClient.exchangeKko(url, HttpMethod.valueOf(API_MODIFY_STATUS[1]), body, Void.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())))
.handle((r, e) -> { .handle((r, e) -> {
if(e != null){ if(e != null){
return webClient.sendError(e); return webClient.sendError(e);
@ -194,7 +195,7 @@ public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implemen
final String url = HOST + API_STATUS[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid()); final String url = HOST + API_STATUS[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid());
return CompletableFuture.supplyAsync(() -> return CompletableFuture.supplyAsync(() ->
webClient.exchangeKko(url, HttpMethod.valueOf(API_STATUS[1]), null, DocStatusResponse.class)) webClient.exchangeKko(url, HttpMethod.valueOf(API_STATUS[1]), null, DocStatusResponse.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())))
.handle((r, e) -> { .handle((r, e) -> {
if(e != null){ if(e != null){
return webClient.sendError(e); return webClient.sendError(e);
@ -216,7 +217,7 @@ public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implemen
@Async("asyncExecutor") @Async("asyncExecutor")
public CompletableFuture<ApiResponseDTO<BulkSendResponses>> requestSendBulk(final BulkSendRequests reqDTO) { public CompletableFuture<ApiResponseDTO<BulkSendResponses>> requestSendBulk(final BulkSendRequests reqDTO) {
return CompletableFuture.supplyAsync(() -> return CompletableFuture.supplyAsync(() ->
webClient.exchangeKko(HOST + API_BULKSEND[0], HttpMethod.valueOf(API_BULKSEND[1]), JsonUtils.toJson(reqDTO), BulkSendResponses.class)) webClient.exchangeKko(HOST + API_BULKSEND[0], HttpMethod.valueOf(API_BULKSEND[1]), JsonUtils.toJson(reqDTO), BulkSendResponses.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())))
.handle((r, e) -> { .handle((r, e) -> {
if(e != null){ if(e != null){
return webClient.sendError(e); return webClient.sendError(e);
@ -255,7 +256,7 @@ public class AsyncKkopayEltrcDocService extends EgovAbstractServiceImpl implemen
} }
return CompletableFuture.supplyAsync(() -> return CompletableFuture.supplyAsync(() ->
webClient.exchangeKko(HOST + API_BULKSTATUS[0], HttpMethod.valueOf(API_BULKSTATUS[1]), JsonUtils.toJson(reqDTO), BulkStatusResponses.class)) webClient.exchangeKko(HOST + API_BULKSTATUS[0], HttpMethod.valueOf(API_BULKSTATUS[1]), JsonUtils.toJson(reqDTO), BulkStatusResponses.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode())))
.handle((r, e) -> { .handle((r, e) -> {
if(e != null){ if(e != null){
return webClient.sendError(e); return webClient.sendError(e);

@ -8,8 +8,6 @@ import java.util.stream.Collectors;
import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolation;
import javax.validation.Validation; import javax.validation.Validation;
import javax.validation.Validator; import javax.validation.Validator;
import kr.xit.biz.ens.model.kakao.KkopayErrorDTO;
import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.DocumentBinderUuid; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.DocumentBinderUuid;
import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.Receiver; import kr.xit.biz.ens.model.kakao.KkopayDocAttrDTO.Receiver;
import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendReq; import kr.xit.biz.ens.model.kakao.KkopayDocBulkDTO.BulkSendReq;
@ -24,12 +22,14 @@ import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendRequest;
import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendResponse; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.SendResponse;
import kr.xit.biz.ens.model.kakao.KkopayDocDTO.ValidTokenRequest; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.ValidTokenRequest;
import kr.xit.biz.ens.model.kakao.KkopayDocDTO.ValidTokenResponse; import kr.xit.biz.ens.model.kakao.KkopayDocDTO.ValidTokenResponse;
import kr.xit.biz.ens.model.kakao.KkopayErrorDTO;
import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.exception.BizRuntimeException;
import kr.xit.core.model.ApiResponseDTO; import kr.xit.core.model.ApiResponseDTO;
import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.spring.annotation.TraceLogging;
import kr.xit.core.spring.util.ApiWebClientUtil; import kr.xit.core.spring.util.ApiWebClientUtil;
import kr.xit.core.support.utils.Checks; import kr.xit.core.support.utils.Checks;
import kr.xit.core.support.utils.JsonUtils; import kr.xit.core.support.utils.JsonUtils;
import kr.xit.ens.kakao.cmm.CmmKakaoUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -107,7 +107,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements
if(Checks.isEmpty(receiver.getBirthday())) Objects.requireNonNull(errors).add("receiver.birthday=받는이 생년월일은 필수입니다."); if(Checks.isEmpty(receiver.getBirthday())) Objects.requireNonNull(errors).add("receiver.birthday=받는이 생년월일은 필수입니다.");
} }
if(Objects.requireNonNull(errors).size() > 0) throw BizRuntimeException.create(errors.toString()); if(Objects.requireNonNull(errors).size() > 0) throw BizRuntimeException.create(errors.toString());
return webClient.exchangeKko(HOST + API_SEND[0], HttpMethod.valueOf(API_SEND[1]), JsonUtils.toJson(reqDTO), SendResponse.class); return webClient.exchangeKko(HOST + API_SEND[0], HttpMethod.valueOf(API_SEND[1]), JsonUtils.toJson(reqDTO), SendResponse.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()));
} }
/** /**
@ -125,7 +125,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements
final String url = HOST final String url = HOST
+ API_VALID_TOKEN[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid()) + API_VALID_TOKEN[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid())
.replace("{tokens}", reqDTO.getToken()); .replace("{tokens}", reqDTO.getToken());
return webClient.exchangeKko(url, HttpMethod.valueOf(API_VALID_TOKEN[1]), null, ValidTokenResponse.class); return webClient.exchangeKko(url, HttpMethod.valueOf(API_VALID_TOKEN[1]), null, ValidTokenResponse.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()));
} }
/** /**
@ -146,7 +146,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements
final String body = "{\"document\": {\"is_detail_read\": true} }"; final String body = "{\"document\": {\"is_detail_read\": true} }";
final String url = HOST + API_MODIFY_STATUS[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid()); final String url = HOST + API_MODIFY_STATUS[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid());
webClient.exchangeKko(url, HttpMethod.valueOf(API_MODIFY_STATUS[1]), body, Void.class); webClient.exchangeKko(url, HttpMethod.valueOf(API_MODIFY_STATUS[1]), body, Void.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()));
} }
/** /**
@ -167,7 +167,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements
validate(reqDTO, null); validate(reqDTO, null);
final String url = HOST + API_STATUS[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid()); final String url = HOST + API_STATUS[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid());
return webClient.exchangeKko(url, HttpMethod.valueOf(API_STATUS[1]), null, DocStatusResponse.class); return webClient.exchangeKko(url, HttpMethod.valueOf(API_STATUS[1]), null, DocStatusResponse.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()));
} }
/** /**
@ -225,7 +225,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements
throw BizRuntimeException.create(errors.toString()); throw BizRuntimeException.create(errors.toString());
} }
return webClient.exchangeKko(HOST + API_BULKSEND[0], HttpMethod.valueOf(API_BULKSEND[1]), JsonUtils.toJson(reqDTO), BulkSendResponses.class); return webClient.exchangeKko(HOST + API_BULKSEND[0], HttpMethod.valueOf(API_BULKSEND[1]), JsonUtils.toJson(reqDTO), BulkSendResponses.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()));
} }
/** /**
@ -255,7 +255,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements
if(errors.size() > 0) { if(errors.size() > 0) {
throw BizRuntimeException.create(errors.toString()); throw BizRuntimeException.create(errors.toString());
} }
return webClient.exchangeKko(HOST + API_BULKSTATUS[0], HttpMethod.valueOf(API_BULKSTATUS[1]), JsonUtils.toJson(reqDTO), BulkStatusResponses.class); return webClient.exchangeKko(HOST + API_BULKSTATUS[0], HttpMethod.valueOf(API_BULKSTATUS[1]), JsonUtils.toJson(reqDTO), BulkStatusResponses.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()));
} }
@Override @Override
@ -266,7 +266,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements
// 유효성 검증 // 유효성 검증
final ValidTokenResponse validTokenRes = webClient.exchangeKko(url, HttpMethod.valueOf(API_VALID_TOKEN[1]), null, final ValidTokenResponse validTokenRes = webClient.exchangeKko(url, HttpMethod.valueOf(API_VALID_TOKEN[1]), null,
ValidTokenResponse.class); ValidTokenResponse.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()));
if(!"USED".equals(validTokenRes.getToken_status())){ if(!"USED".equals(validTokenRes.getToken_status())){
return ApiResponseDTO.error(validTokenRes.getError_code(), validTokenRes.getError_message()); return ApiResponseDTO.error(validTokenRes.getError_code(), validTokenRes.getError_message());
@ -278,7 +278,7 @@ public class KkopayEltrcDocService extends EgovAbstractServiceImpl implements
// 정상 : HttpStatus.NO_CONTENT(204) return // 정상 : HttpStatus.NO_CONTENT(204) return
// error : body에 error_code, error_message return // error : body에 error_code, error_message return
final KkopayErrorDTO errorDTO = webClient.exchangeKko(url2, HttpMethod.valueOf(API_MODIFY_STATUS[1]), body, KkopayErrorDTO.class); final KkopayErrorDTO errorDTO = webClient.exchangeKko(url2, HttpMethod.valueOf(API_MODIFY_STATUS[1]), body, KkopayErrorDTO.class, CmmKakaoUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()));
if(errorDTO != null){ if(errorDTO != null){
return ApiResponseDTO.error(errorDTO.getErrorCode(), errorDTO.getErrorMessage()); return ApiResponseDTO.error(errorDTO.getErrorCode(), errorDTO.getErrorMessage());
} }

@ -13,7 +13,6 @@ import kr.xit.core.model.ApiResponseDTO;
import kr.xit.ens.kakao.service.IKkopayEltrcDocService; import kr.xit.ens.kakao.service.IKkopayEltrcDocService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -40,9 +39,6 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(value = "/api/ens/kakao/v1") @RequestMapping(value = "/api/ens/kakao/v1")
public class KkopayEltrcDocController { public class KkopayEltrcDocController {
@Value("${contract.kakao.token}")
private String accessToken;
private final IKkopayEltrcDocService service; private final IKkopayEltrcDocService service;
/** /**
@ -56,27 +52,33 @@ public class KkopayEltrcDocController {
@Operation(summary = "문서발송 요청", description = "카카오페이 전자문서 서버로 문서발송 처리를 요청") @Operation(summary = "문서발송 요청", description = "카카오페이 전자문서 서버로 문서발송 처리를 요청")
@io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = { @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = {
@Content(mediaType = "application/json", examples = { @Content(mediaType = "application/json", examples = {
@ExampleObject(value = "{\"document\": {\n" @ExampleObject(value = """
+ " \"title\": \"문서 제목\",\n" {
+ " \"read_expired_sec\": 3600,\n" "document": {
+ " \"hash\": \"6EFE827AC88914DE471C621AE\",\n" "title": "문서 제목",
+ " \"common_categories\": [\n" "read_expired_sec": 3600,
+ " \"NOTICE\"\n" "hash": "6EFE827AC88914DE471C621AE",
+ " ],\n" "common_categories": [
+ " \"receiver\": {\n" "NOTICE"
+ " \"phone_number\": \"01093414345\",\n" ],
+ " \"name\": \"김지호\",\n" "receiver": {
+ " \"birthday\": \"19831218\",\n" "phone_number": "01093414345",
+ " \"is_required_verify_name\": false\n" "name": "김지호",
+ " },\n" "birthday": "19831218",
+ " \"property\": {\n" "is_required_verify_name": false
+ " \"link\": \"http://ip:8081/api/kakaopay/v1/ott\",\n" },
+ " \"cs_number\": \"02-123-4567\",\n" "property": {
+ " \"cs_name\": \"콜센터\",\n" "link": "http://ip:8081/api/kakaopay/v1/ott",
+ " \"payload\": \"payload 파라미터 입니다.\",\n" "cs_number": "02-123-4567",
+ " \"message\": \"해당 안내문은 다음과 같습니다.\"\n" "cs_name": "콜센터",
+ " }\n" "payload": "payload 파라미터 입니다.",
+ " }}") "message": "해당 안내문은 다음과 같습니다."
}
},
"signguCode": "88328",
"ffnlgCode": "11"
}
""")
}) })
}) })
@PostMapping(value = "/documents", produces = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/documents", produces = MediaType.APPLICATION_JSON_VALUE)

@ -14,8 +14,8 @@ contract:
kakao: kakao:
bulk-max-cnt: 10 bulk-max-cnt: 10
host: https://docs-gw.kakaopay.com host: https://docs-gw.kakaopay.com
token: dd394da7f66211eb9cbe46e139ceffc2 # token: dd394da7f66211eb9cbe46e139ceffc2
uuid: CON-41ef0535f67211ebbdedd2e6ed332381 # uuid: CON-41ef0535f67211ebbdedd2e6ed332381
api: api:
send: /v1/documents;POST send: /v1/documents;POST
validToken: /v1/{document_binder_uuid}/tokens/{tokens};GET validToken: /v1/{document_binder_uuid}/tokens/{tokens};GET

@ -5,4 +5,4 @@ fail.api.nice.info=NICE \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5
fail.api.nice.revoke.token=\uD1A0\uD070(NICE) \uD3D0\uAE30\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4 fail.api.nice.revoke.token=\uD1A0\uD070(NICE) \uD3D0\uAE30\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4
fail.api.nice.invalid.tranId=NICE \uC778\uC99D \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4(TRAN_ID \uBD88\uC77C\uCE58) fail.api.nice.invalid.tranId=NICE \uC778\uC99D \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4(TRAN_ID \uBD88\uC77C\uCE58)
fail.api.kt.info=KT \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. fail.api.rlaybsnm.info=\uBB38\uC11C\uC911\uACC4\uC790 \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.

@ -6,13 +6,13 @@ import java.util.List;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.Digits; import javax.validation.constraints.Digits;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import kr.xit.core.model.IApiResponse;
import kr.xit.biz.common.ApiConstants; import kr.xit.biz.common.ApiConstants;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import kr.xit.core.model.IApiResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
/** /**
@ -188,7 +188,7 @@ public class KkopayDocAttrDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public static class DocumentBinderUuid implements IApiResponse { public static class DocumentBinderUuid extends CmmEnsRequestDTO implements IApiResponse {
/** /**
* (max:40) - * (max:40) -
*/ */

@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List; import java.util.List;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -35,7 +36,7 @@ public class KkopayDocBulkDTO extends KkopayDocAttrDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
public static class BulkSendRequests { public static class BulkSendRequests extends CmmEnsRequestDTO {
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
@Valid @Valid
private List<BulkSendReq> documents; private List<BulkSendReq> documents;
@ -126,7 +127,7 @@ public class KkopayDocBulkDTO extends KkopayDocAttrDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
public static class BulkStatusRequests { public static class BulkStatusRequests extends CmmEnsRequestDTO {
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
@Valid @Valid
private List<String> document_binder_uuids; private List<String> document_binder_uuids;

@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.Digits; import javax.validation.constraints.Digits;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import kr.xit.core.model.IApiResponse; import kr.xit.core.model.IApiResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -38,7 +39,7 @@ public class KkopayDocDTO extends KkopayDocAttrDTO {
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
public static class SendRequest { public static class SendRequest extends CmmEnsRequestDTO {
@Schema(requiredMode = Schema.RequiredMode.REQUIRED) @Schema(requiredMode = Schema.RequiredMode.REQUIRED)
@Valid @Valid
private RequestSend document; private RequestSend document;
@ -98,6 +99,13 @@ public class KkopayDocDTO extends KkopayDocAttrDTO {
@NotEmpty(message = "카카오페이 전자문서 서버 토큰은 필수입니다(max:50)") @NotEmpty(message = "카카오페이 전자문서 서버 토큰은 필수입니다(max:50)")
@Length(max = 50) @Length(max = 50)
private String token; private String token;
// /**
// * 카카오페이 문서식별번호(max:40) - 필수
// */
// @Schema(requiredMode = Schema.RequiredMode.REQUIRED, title = "카카오페이 문서식별번호(max:40)", example = "BIN-ff806328863311ebb61432ac599d6150")
// @Size(min = 1, max = 40, message = "카카오페이 문서식별번호는 필수입니다(max:40)")
// private String document_binder_uuid;
} }
//----------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------

@ -16,7 +16,6 @@ import kr.xit.core.spring.util.error.ServerError;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -53,14 +52,15 @@ import reactor.core.publisher.Mono;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class ApiWebClientUtil { public class ApiWebClientUtil {
@Value("${contract.kakao.token:}")
private String kkoAccessToken;
@Value("${contract.kakao.uuid:}")
private String kkoContractUuid;
private static final String AUTH_TYPE_BEARER = "Bearer"; private static final String AUTH_TYPE_BEARER = "Bearer";
private final WebClientConfig webClientConfig; private final WebClientConfig webClientConfig;
private enum EnsDIV{
KKO,
KT,
PPLUS
};
public <T> T get(final String url, final Class<T> responseDtoClass, Map<String, String> headerMap) { public <T> T get(final String url, final Class<T> responseDtoClass, Map<String, String> headerMap) {
return webClientConfig.webClient().method(HttpMethod.GET) return webClientConfig.webClient().method(HttpMethod.GET)
.uri(url) .uri(url)
@ -86,21 +86,22 @@ public class ApiWebClientUtil {
.block(); .block();
} }
public <T> T exchangeKko(final String url, final HttpMethod method, final Object body, final Class<T> rtnClzz) { public <T> T exchangeKko(final String url, final HttpMethod method, final Object body, final Class<T> rtnClzz, final CmmEnsRlaybsnmDTO ensDTO) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
map.put(HttpHeaders.AUTHORIZATION, map.put(HttpHeaders.AUTHORIZATION,
String.format("%s %s", Constants.JwtToken.GRANT_TYPE.getCode(), kkoAccessToken)); String.format("%s %s", Constants.JwtToken.GRANT_TYPE.getCode(), ensDTO.getKakaoAccessToken()));
map.put(Constants.HeaderName.UUID.getCode(), kkoContractUuid); map.put(Constants.HeaderName.UUID.getCode(), ensDTO.getKakaoContractUuid());
return exchange(url, method, body, rtnClzz, map); return exchange(url, method, body, rtnClzz, map);
} }
public <T> T exchangeKt(final String url, final HttpMethod method, final Object body, final Class<T> rtnClzz, final CmmEnsRlaybsnmDTO ktMnsInfo) { public <T> T exchangeKt(final String url, final HttpMethod method, final Object body, final Class<T> rtnClzz, final CmmEnsRlaybsnmDTO ensDTO) {
final Map<String,String> headerMap = new HashMap<>(); final Map<String,String> headerMap = new HashMap<>();
headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
headerMap.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, ktMnsInfo.getKtAccessToken())); headerMap.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, ensDTO.getKtAccessToken()));
headerMap.put("client-id", ktMnsInfo.getKtClientId()); headerMap.put("client-id", ensDTO.getKtClientId());
headerMap.put("client-tp", "10"); headerMap.put("client-tp", "10");
return exchange(url, method, body, rtnClzz, headerMap); return exchange(url, method, body, rtnClzz, headerMap);
@ -205,6 +206,28 @@ public class ApiWebClientUtil {
return ErrorParse.extractError(e.getCause()); return ErrorParse.extractError(e.getCause());
} }
// private Map<String,String> getHeaderMap(final EnsDIV ensDIV, final CmmEnsRlaybsnmDTO ensDTO){
// Map<String, String> map = new HashMap<>();
//
// switch(ensDIV){
// case KKO:
// map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
// map.put(HttpHeaders.AUTHORIZATION,
// String.format("%s %s", Constants.JwtToken.GRANT_TYPE.getCode(), ensDTO.getKakaoAccessToken()));
// map.put(Constants.HeaderName.UUID.getCode(), ensDTO.getKakaoContractUuid());
// break;
// case KT:
// map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
// map.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, ensDTO.getKtAccessToken()));
// map.put("client-id", ensDTO.getKtClientId());
// map.put("client-tp", "10");
// break;
// default:
// throw BizRuntimeException.create("서비스 불가한 문서중계자 입니다");
// }
// return map;
// }
private URI createUrl(final String endPoint, final String... value) { private URI createUrl(final String endPoint, final String... value) {
return UriComponentsBuilder.fromUriString(endPoint) return UriComponentsBuilder.fromUriString(endPoint)
.build(value); .build(value);
@ -218,7 +241,7 @@ public class ApiWebClientUtil {
return headers; return headers;
} }
ExchangeFilterFunction errorHandler() { private ExchangeFilterFunction errorHandler() {
return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> { return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> {
HttpStatus status = clientResponse.statusCode(); HttpStatus status = clientResponse.statusCode();

Loading…
Cancel
Save