From 8484377f7a1966e54532ae6c1e02afb4488b0082 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Wed, 4 Sep 2024 17:27:56 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=ED=86=A1=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xit/ens/core/config/SpringDocConfig.java | 9 + .../kkotalk/service/KkoTalkService.java | 4 +- .../event/KkoTalkSendEventListener.java | 77 +++++++ .../event/KkoTalkSendRealtimeEvent.java | 17 ++ .../event/KkoTalkSendReserveEvent.java | 17 ++ .../service/support/IKkoTalkApiService.java | 93 -------- .../service/support/KkoTalkApiService.java | 34 +-- .../service/support/KkoTalkRsltFetcher.java | 2 +- .../service/support/KkoTalkSender.java | 2 +- .../kkotalk/web/KkotalkApiController.java | 8 +- .../kkotalk/web/KkotalkController.java | 198 ++++++++++++++++++ 11 files changed, 329 insertions(+), 132 deletions(-) create mode 100644 src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendEventListener.java create mode 100644 src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendRealtimeEvent.java create mode 100644 src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendReserveEvent.java delete mode 100644 src/main/java/cokr/xit/ens/modules/kkotalk/service/support/IKkoTalkApiService.java create mode 100644 src/main/java/cokr/xit/ens/modules/kkotalk/web/KkotalkController.java diff --git a/src/main/java/cokr/xit/ens/core/config/SpringDocConfig.java b/src/main/java/cokr/xit/ens/core/config/SpringDocConfig.java index 8019606..2cb4c0d 100644 --- a/src/main/java/cokr/xit/ens/core/config/SpringDocConfig.java +++ b/src/main/java/cokr/xit/ens/core/config/SpringDocConfig.java @@ -133,6 +133,15 @@ public class SpringDocConfig { .build(); } + @Profile({"local", "prod", "dev"}) + @Bean + public GroupedOpenApi kkoTalkApiDoc() { + return GroupedOpenApi.builder() + .group("CMPT. 전자고지-kakaotalk 인증톡 API") + .pathsToMatch("/kko/talk/**") + .build(); + } + @Profile({"local", "prod", "dev"}) @Bean public GroupedOpenApi nvSigntalkApiDoc() { diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/service/KkoTalkService.java b/src/main/java/cokr/xit/ens/modules/kkotalk/service/KkoTalkService.java index 3eda39f..21fb019 100644 --- a/src/main/java/cokr/xit/ens/modules/kkotalk/service/KkoTalkService.java +++ b/src/main/java/cokr/xit/ens/modules/kkotalk/service/KkoTalkService.java @@ -28,8 +28,8 @@ import cokr.xit.ens.modules.kkomydoc.domain.SendDetailKkoMydocTokenHist; import cokr.xit.ens.modules.kkomydoc.domain.repository.SendDetailKkoMydocTokenHistRepository; import cokr.xit.ens.modules.kkotalk.model.KkotalkApiDTO; import cokr.xit.ens.modules.kkotalk.model.KkotalkDTO; -import cokr.xit.ens.modules.kkotalk.service.support.IKkoTalkApiService; import cokr.xit.ens.modules.kkotalk.service.support.KkoTalkAcceptor; +import cokr.xit.ens.modules.kkotalk.service.support.KkoTalkApiService; import cokr.xit.ens.modules.kkotalk.service.support.KkoTalkMaker; import cokr.xit.ens.modules.kkotalk.service.support.KkoTalkRsltFetcher; import cokr.xit.ens.modules.kkotalk.service.support.KkoTalkRsltProvider; @@ -49,7 +49,7 @@ public class KkoTalkService { private final KkoTalkRsltFetcher kkoTalkRsltFetcher; private final KkoTalkRsltProvider kkoTalkRsltProvider; - private final IKkoTalkApiService kkoTalkApi; + private final KkoTalkApiService kkoTalkApi; private final SendMastRepository sendMastRepository; private final SendDetailKkoMydocTokenHistRepository sendDetailKkoMydocTokenHistRepository; diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendEventListener.java b/src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendEventListener.java new file mode 100644 index 0000000..123b78a --- /dev/null +++ b/src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendEventListener.java @@ -0,0 +1,77 @@ +package cokr.xit.ens.modules.kkotalk.service.event; + +import org.springframework.core.annotation.Order; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; +import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.event.TransactionalEventListener; + +import cokr.xit.ens.core.aop.EnsResponseVO; +import cokr.xit.ens.core.exception.code.EnsErrCd; +import cokr.xit.ens.modules.kkotalk.service.KkoTalkService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Component +@RequiredArgsConstructor +public class KkoTalkSendEventListener { + private final KkoTalkService kkoTalkService; + + @Order(1) + @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) + public void sendRealtime(KkoTalkSendRealtimeEvent event) { + event.getSendMastIds().stream() + .forEach(sendMastId -> { + StringBuffer sb = new StringBuffer(); + sb.append("\n=======================================================") + .append("\n[ENS] 카카오톡 인증톡 실시간전송") + .append("\n요청ID: " + sendMastId); + + EnsResponseVO responseVO = kkoTalkService.remake(sendMastId); + sb.append("\n제작 결과: " + responseVO.toString()); + if (!EnsErrCd.OK.equals(responseVO.getErrCode())) { + sb.append("\n======================================================="); + log.info(sb.toString()); + return; + } + + responseVO = kkoTalkService.sendBulk(sendMastId); + sb.append("\n전송요청 결과: " + responseVO.toString()); + if (!EnsErrCd.OK.equals(responseVO.getErrCode())) { + sb.append("\n======================================================="); + log.info(sb.toString()); + return; + } + + responseVO = kkoTalkService.statBulk(sendMastId); + sb.append("\n상태갱신 결과: " + responseVO.toString()) + .append("\n======================================================="); + log.info(sb.toString()); + + if (event.getCallback() != null) + event.getCallback().execute(); + }); + } + + @Async + @Order(1) + @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) + public void sendReserve(KkoTalkSendReserveEvent event) { + event.getSendMastIds().stream() + .forEach(sendMastId -> { + StringBuffer sb = new StringBuffer(); + + EnsResponseVO responseVO = kkoTalkService.remake(sendMastId); + sb.append("\n=======================================================") + .append("\n[ENS] 카카오톡 인증톡 예약전송") + .append("\n요청ID: " + sendMastId) + .append("\n제작 결과: " + responseVO.toString()) + .append("\n======================================================="); + log.info(sb.toString()); + + if (event.getCallback() != null) + event.getCallback().execute(); + }); + } +} diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendRealtimeEvent.java b/src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendRealtimeEvent.java new file mode 100644 index 0000000..9be4ed9 --- /dev/null +++ b/src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendRealtimeEvent.java @@ -0,0 +1,17 @@ +package cokr.xit.ens.modules.kkotalk.service.event; + +import java.util.List; + +import cokr.xit.ens.core.eventlistner.adaptor.EnsAMSCallbackAdaptor; +import lombok.Builder; +import lombok.Getter; + +@Builder +@Getter +public class KkoTalkSendRealtimeEvent { + + private List sendMastIds; + + private EnsAMSCallbackAdaptor callback; + +} diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendReserveEvent.java b/src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendReserveEvent.java new file mode 100644 index 0000000..18aa6fe --- /dev/null +++ b/src/main/java/cokr/xit/ens/modules/kkotalk/service/event/KkoTalkSendReserveEvent.java @@ -0,0 +1,17 @@ +package cokr.xit.ens.modules.kkotalk.service.event; + +import java.util.List; + +import cokr.xit.ens.core.eventlistner.adaptor.EnsAMSCallbackAdaptor; +import lombok.Builder; +import lombok.Getter; + +@Builder +@Getter +public class KkoTalkSendReserveEvent { + + private List sendMastIds; + + private EnsAMSCallbackAdaptor callback; + +} diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/IKkoTalkApiService.java b/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/IKkoTalkApiService.java deleted file mode 100644 index d39bd8e..0000000 --- a/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/IKkoTalkApiService.java +++ /dev/null @@ -1,93 +0,0 @@ -package cokr.xit.ens.modules.kkotalk.service.support; - -import cokr.xit.ens.modules.kkotalk.model.KkotalkApiDTO; -import cokr.xit.ens.modules.kkotalk.model.KkotalkDTO; - -/** - *
- * description : 카카오 페이 전자 문서 발송 요청 인터 페이스
- * packageName : kr.xit.ens.kakao.talk.service
- * fileName    : IKkopayEltrcDocService
- * author      : julim
- * date        : 2023-04-28
- * ======================================================================
- * 변경일         변경자        변경 내용
- * ----------------------------------------------------------------------
- * 2023-04-28    julim       최초 생성
- *
- * 
- */ -public interface IKkoTalkApiService { - - /** - *
-     * 모바일웹 연계 문서발송 요청
-     * -.이용기관 서버에서 전자문서 서버로 문서발송 처리를 요청합니다.
-     * 
- * @param reqDTO KkotalkApiDTO.SendRequest - * @return KkotalkApiDTO.SendResponse - */ - KkotalkDTO.SendResponse requestSend(final KkotalkDTO.SendRequest reqDTO); - - /** - *
-     * 토큰 유효성 검증(Redirect URL  접속 허용/불허)
-     * 
- * @param reqDTO KkotalkApiDTO.ValidTokenRequest - * @return KkotalkApiDTO.ValidTokenResponse> - */ - KkotalkApiDTO.ValidTokenResponse validToken(final KkotalkApiDTO.ValidTokenRequest reqDTO); - - /** - *
-     * 문서 열람 처리 API
-     * -.문서에 대해서 열람 상태로 변경. 사용자가 문서열람 시(OTT 검증 완료 후 페이지 로딩 완료 시점) 반드시 문서 열람 상태 변경 API를 호출해야 함.
-     * -.미 호출 시 아래와 같은 문제 발생
-     * 1)유통증명시스템을 사용하는 경우 해당 API를 호출한 시점으로 열람정보가 등록되어 미 호출 시 열람정보가 등록 되지 않음.
-     * 2)문서상태조회 API(/v1/envelopes/${ENVELOPE_ID}/read) 호출 시 read_at최초 열람시간) 데이터가 내려가지 않음.
-     * 
- * @param reqDTO KkotalkDTO.EnvelopeId - */ - KkotalkApiDTO.KkotalkErrorDTO modifyStatus(final KkotalkDTO.EnvelopeId reqDTO); - - - /** - *
-     * 문서 상태 조회 API
-     * -.이용기관 서버에서 카카오페이 전자문서 서버로 문서 상태에 대한 조회를 요청 합니다.
-     * : 발송된 문서의 진행상태를 알고 싶은 경우, flow와 상관없이 요청 가능
-     * : polling 방식으로 호출할 경우, 호출 간격은 5초를 권장.
-     * -.doc_box_status 상태변경순서
-     * : RECEIVE(수신, 미처리) > READ(열람)/EXPIRED
-     * 
- * @param reqDTO KkotalkDTO.EnvelopeId - * @return KkotalkApiDTO.EnvelopeStatusResponse - */ - KkotalkApiDTO.EnvelopeStatusResponse findStatus(final KkotalkApiDTO.EnvelopeId reqDTO); - - /** - *
-     * 대량(bulk) 문서발송 요청
-     * -.이용기관 서버에서 카카오페이 내문서함 서버로 대량(bulk) 문서발송 처리를 요청합니다.
-     * 
- * @param reqDTO KkopayDocBulkDTO.BulkSendRequests - * @return KkopayDocBulkDTO.BulkSendResponses - */ - KkotalkDTO.BulkSendResponse requestSendBulk(final KkotalkDTO.BulkSendRequest reqDTO); - - /** - *
-     * 대량(bulk) 문서 상태 조회 API
-     * -.이용기관 서버에서 카카오페이 전자문서 서버로 문서 상태에 대한 조회를 요청 합니다.
-     * : 발송된 문서의 진행상태를 알고 싶은 경우, flow와 상관없이 요청 가능
-     * : polling 방식으로 호출할 경우, 호출 간격은 5초를 권장.
-     * : RECEIVED(수신,미수신) > READ(열람)/EXPIRED
-     * 
- * @param reqDTO KkotalkDTO.BulkStatusRequest - * @return KkotalkDTO.BulkStatusResponse - */ - KkotalkDTO.BulkStatusResponse findBulkStatus(final KkotalkDTO.BulkStatusRequest reqDTO); - - - //KkotalkApiDTO.ValidTokenResponse findKkotalkReadyAndMblPage(KkotalkApiDTO.ValidTokenRequest reqDTO); -} diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkApiService.java b/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkApiService.java index c394c64..21949c3 100644 --- a/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkApiService.java +++ b/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkApiService.java @@ -45,8 +45,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j @RequiredArgsConstructor @Component -public class KkoTalkApiService implements - IKkoTalkApiService { +public class KkoTalkApiService { @Value("${contract.kakao.talk.host}") private String HOST; @@ -78,9 +77,8 @@ public class KkoTalkApiService implements * -.이용기관 서버에서 전자문서 서버로 문서발송 처리 요청 * * @param reqDTO KkoPayEltrDocDTO.RequestSendReq - * @return ApiResponseDTO + * @return KkotalkDTO.SendResponse */ - @Override public KkotalkDTO.SendResponse requestSend(final KkotalkDTO.SendRequest reqDTO) { if(Checks.isEmpty(reqDTO.getProductCode())){ throw BizRuntimeException.create("상품 코드는 필수 입니다."); @@ -114,9 +112,8 @@ public class KkoTalkApiService implements * 토큰 유효성 검증(Redirect URL 접속 허용/불허) : GET * * @param reqDTO KkopayDocDTO.ValidTokenRequest - * @return ApiResponseDTO + * @return KkotalkApiDTO.ValidTokenResponse */ - @Override public KkotalkApiDTO.ValidTokenResponse validToken(final KkotalkApiDTO.ValidTokenRequest reqDTO) { validate(reqDTO, null); @@ -140,7 +137,6 @@ public class KkoTalkApiService implements * * @param reqDTO KkopayDocAttrDTO.EnvelopeId */ - @Override public KkotalkApiDTO.KkotalkErrorDTO modifyStatus(final KkotalkDTO.EnvelopeId reqDTO){ validate(reqDTO.getEnvelopeId(), null); @@ -160,7 +156,6 @@ public class KkoTalkApiService implements * @param reqDTO KkotalkDTO.EnvelopeId * @return KkotalkApiDTO.EnvelopeStatusResponse */ - @Override public KkotalkApiDTO.EnvelopeStatusResponse findStatus(final KkotalkApiDTO.EnvelopeId reqDTO){ validate(reqDTO, null); @@ -182,7 +177,6 @@ public class KkoTalkApiService implements * @param reqDTO KkotalkDTO.BulkSendRequest * @return KkotalkDTO.BulkSendResponse */ - @Override public KkotalkDTO.BulkSendResponse requestSendBulk(final KkotalkDTO.BulkSendRequest reqDTO) { if(Checks.isEmpty(reqDTO.getProductCode())){ throw BizRuntimeException.create("상품 코드는 필수 입니다."); @@ -249,7 +243,6 @@ public class KkoTalkApiService implements * @param reqDTO KkotalkDTO.BulkStatusRequest * @return KkotalkDTO.BulkStatusResponse */ - @Override public KkotalkDTO.BulkStatusResponse findBulkStatus(final KkotalkDTO.BulkStatusRequest reqDTO) { List errors = new ArrayList<>(); @@ -272,27 +265,6 @@ public class KkoTalkApiService implements getRlaybsnmInfo(reqDTO)); } - // @Override - // public KkotalkApiDTO.ValidTokenResponse findKkotalkReadyAndMblPage(final KkotalkApiDTO.ValidTokenRequest reqDTO) { - // final String url = HOST + API_VALID_TOKEN[0].replace(ENVELOPE_ID, reqDTO.getEnvelopeId()) - // .replace("{TOKEN}", reqDTO.getToken()); - // - // // 유효성 검증 - // final KkotalkApiDTO.ValidTokenResponse validTokenRes = webClient.exchangeKkotalk(url, HttpMethod.valueOf(API_VALID_TOKEN[1]), null, - // KkotalkApiDTO.ValidTokenResponse.class, getRlaybsnmInfo(reqDTO)); - // - // // 문서상태 변경 - // final String url2 = HOST + API_MODIFY_STATUS[0].replace(ENVELOPE_ID, reqDTO.getEnvelopeId()); - // - // // 정상 : HttpStatus.NO_CONTENT(204) return - // // error : body에 error_code, error_message return - // final KkotalkApiDTO.KkotalkErrorDTO errorDTO = webClient.exchangeKkotalk(url2, HttpMethod.valueOf(API_MODIFY_STATUS[1]), null, KkotalkApiDTO.KkotalkErrorDTO.class, getRlaybsnmInfo(reqDTO)); - // if(errorDTO != null){ - // return ApiResponseDTO.error(errorDTO.getErrorCode(), errorDTO.getErrorMessage()); - // } - // return ApiResponseDTO.success(); - // } - //------------------------------------------------------------------------------------------------------------------- private static List validate(T t, List errList) { final Set> list = validator.validate(t); diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkRsltFetcher.java b/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkRsltFetcher.java index c01cc48..942fa8c 100644 --- a/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkRsltFetcher.java +++ b/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkRsltFetcher.java @@ -52,7 +52,7 @@ public class KkoTalkRsltFetcher extends ResultProcTemplate { private final IKkoTalkMapper talkMapper; private final SendDetailKkoMydocStatHistRepository sendDetailKkoMydocStatHistRepository; private final OrgMngService orgMngService; - private final IKkoTalkApiService kkoTalkApi; + private final KkoTalkApiService kkoTalkApi; //private final KkoMydocApiSpec kkoMydocApi; @Value("${contract.kakao.pay.mydoc.api.bulksend-batch-unit}") private int SEND_BATCH_UNIT; diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkSender.java b/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkSender.java index 3a32245..0ae1b06 100644 --- a/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkSender.java +++ b/src/main/java/cokr/xit/ens/modules/kkotalk/service/support/KkoTalkSender.java @@ -58,7 +58,7 @@ public class KkoTalkSender extends SendProcTemplate { private final SendDetailKkoMydocReqHistRepository sendDetailKkoMydocReqHistRepository; private final OrgMngService orgMngService; //private final KkoMydocApiSpec kkoMydocApi; - private final IKkoTalkApiService kkoTalkApi; + private final KkoTalkApiService kkoTalkApi; @Value("${contract.kakao.pay.mydoc.api.bulksend-batch-unit}") private int SEND_BATCH_UNIT; diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/web/KkotalkApiController.java b/src/main/java/cokr/xit/ens/modules/kkotalk/web/KkotalkApiController.java index d2f53bd..dea8c87 100644 --- a/src/main/java/cokr/xit/ens/modules/kkotalk/web/KkotalkApiController.java +++ b/src/main/java/cokr/xit/ens/modules/kkotalk/web/KkotalkApiController.java @@ -10,7 +10,7 @@ import cokr.xit.ens.core.aop.ApiResponseDTO; import cokr.xit.ens.core.aop.IApiResponse; import cokr.xit.ens.modules.kkotalk.model.KkotalkApiDTO; import cokr.xit.ens.modules.kkotalk.model.KkotalkDTO; -import cokr.xit.ens.modules.kkotalk.service.support.IKkoTalkApiService; +import cokr.xit.ens.modules.kkotalk.service.support.KkoTalkApiService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; @@ -32,13 +32,13 @@ import lombok.extern.slf4j.Slf4j; * * */ -@Tag(name = "KkotalkController", description = "카카오톡 전자문서 API") +@Tag(name = "KkotalkApiController", description = "카카오톡 인증톡 API") @Slf4j @RequiredArgsConstructor @RestController -@RequestMapping(value = "/api/ens/kakao/v2") +@RequestMapping(value = "/kko/talk/api") public class KkotalkApiController { - private final IKkoTalkApiService service; + private final KkoTalkApiService service; /** *
diff --git a/src/main/java/cokr/xit/ens/modules/kkotalk/web/KkotalkController.java b/src/main/java/cokr/xit/ens/modules/kkotalk/web/KkotalkController.java
new file mode 100644
index 0000000..e369f16
--- /dev/null
+++ b/src/main/java/cokr/xit/ens/modules/kkotalk/web/KkotalkController.java
@@ -0,0 +1,198 @@
+package cokr.xit.ens.modules.kkotalk.web;
+
+import java.util.Map;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import cokr.xit.ens.core.aop.EnsResponseVO;
+import cokr.xit.ens.core.exception.EnsException;
+import cokr.xit.ens.core.exception.code.EnsErrCd;
+import cokr.xit.ens.modules.kkotalk.mapper.IKkoTalkMapper;
+import cokr.xit.ens.modules.kkotalk.model.KkotalkDTO;
+import cokr.xit.ens.modules.kkotalk.service.KkoTalkService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.ExampleObject;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 
+ * description : 카카오톡 전자 문서 발송 controller
+ * packageName : kr.xit.ens.kakao.talk.web
+ * fileName    : KkotalkEltrcDocController
+ * author      : julim
+ * date        : 2024-08-12
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2024-08-12    julim       최초 생성
+ *
+ * 
+ */ +@Tag(name = "KkotalkController", description = "카카오톡 인증톡") +@Slf4j +@RequiredArgsConstructor +@RestController +@RequestMapping(value = "/kko/talk") +public class KkotalkController { + private final KkoTalkService service; + private final IKkoTalkMapper talkMapper; + + @Operation(summary = "접수") + @PostMapping(value = "/accept", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity accept(@RequestBody KkotalkDTO.KkoTalkAcceptReqDTO reqDTO) { + EnsResponseVO responseVO = service.accept(reqDTO); + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } + + + @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = { + @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "Sample Example..." + , summary = "제작" + , value = "{\"sendMastId\": 1}") + }) + }) + @Operation(summary = "제작") + @PostMapping(value = "/make", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity make(@RequestBody Map mParam) { + + EnsResponseVO responseVO = service.remake(mParam.get("sendMastId")); + + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } + + + @Operation(summary = "제작(일괄)") + // @PutMapping(value = "/kko/mydoc/make/all", produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "/make/all", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity makeAll() { + + EnsResponseVO responseVO = service.makeAll(); + + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } + + + @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = { + @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "Sample Example..." + , summary = "(대량)전송요청" + , value = "{\"sendMastId\": 1}") + }) + }) + @Operation(summary = "(대량)전송요청") + @PostMapping(value = "/send/bulk", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity sendBulk(@RequestBody Map mParam) { + EnsResponseVO responseVO = service.sendBulk(mParam.get("sendMastId")); + + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } + + @Operation(summary = "(대량)전송요청 일괄") + @PostMapping(value = "/send/bulk/all", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity sendBulkAll() { + EnsResponseVO responseVO = service.sendBulkAll(); + + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } + + + @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = { + @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "Sample Example..." + , summary = "(대량)문서상태 갱신" + , value = "{\"sendMastId\": 1}") + }) + }) + @Operation(summary = "(대량)문서상태 갱신") + @PostMapping(value = "/stat/bulk", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity statBulk(@RequestBody Map mParam) { + + EnsResponseVO responseVO = service.statBulk(mParam.get("sendMastId")); + + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } + + @Operation(summary = "(대량)문서상태 일괄 갱신") + // @PutMapping(value = "/kko/mydoc/stat/bulk/all", produces = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(value = "/stat/bulk/all", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity statBulkAll() { + + EnsResponseVO responseVO = service.statBulkAll(); + + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } + + + @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = { + @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "Sample Example..." + , summary = "토큰(OTT) 검증" + , value = "{\"envelopeId\": \"BIN-ff806328863311ebb61432ac599d6150\", \"token\": \"ZDU3NGU1ZTYtNTk2Yy99OGNjLWJiYjUtYjZmMjI9NzRhOTA4\", \"externalId\": \"A0001\"}") + }) + }) + @Operation(summary = "토큰(OTT) 검증") + @PostMapping(value = "/token/verify", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity tokenVerify(@RequestBody Map mParam) { + + final String envelopeId = mParam.get("envelopeId"); + final String token = mParam.get("token"); + final String externalId = mParam.get("externalId"); + + + KkotalkDTO.SendDetailKkoTalkDTO sendDetail = talkMapper.findFetchByExternalIdAndEnvelopeId(externalId, envelopeId) + .orElseThrow(() -> new EnsException(EnsErrCd.ERR404, "문서를 찾을 수 없습니다.")); + + EnsResponseVO responseVO = service.tokenVerify("getOrgCd()", envelopeId, token, externalId); + + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } + + @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = { + @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "Sample Example..." + , summary = "문서열람 완료처리" + , value = "{\"envelopeId\": \"BIN-ff806328863311ebb61432ac599d6150\"}") + }) + }) + @Operation(summary = "문서열람 완료처리") + @PostMapping(value = "/read/cmplt", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity readCmplt(@RequestBody Map mParam) { + + final String envelopeId = mParam.get("envelopeId"); + + KkotalkDTO.SendDetailKkoTalkDTO sendDetail = talkMapper.findFetchByExternalIdAndEnvelopeId(null, envelopeId) + .orElseThrow(() -> new EnsException(EnsErrCd.ERR404, "문서를 찾을 수 없습니다.")); + + EnsResponseVO responseVO = service.readCmplt("getOrgCd()", envelopeId); + + + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } + + @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = { + @Content(mediaType = "application/json", examples = { + @ExampleObject(name = "Sample Example..." + , summary = "전송결과 가져오기" + , value = "{\"sendMastId\": 1}") + }) + }) + @Operation(summary = "전송결과 가져오기") + @PostMapping(value = "/send/result/provide", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity sendResultProvide(@RequestBody Map mParam) { + + EnsResponseVO responseVO = service.sendResultProvide(mParam.get("sendMastId")); + + + return new ResponseEntity<>(responseVO, HttpStatus.OK); + } +}