diff --git a/mens-api/src/main/java/kr/xit/biz/mbl/mapper/IMobilePageMapper.java b/mens-api/src/main/java/kr/xit/biz/mbl/mapper/IMobilePageMapper.java index dc33bda..e0bb8d6 100644 --- a/mens-api/src/main/java/kr/xit/biz/mbl/mapper/IMobilePageMapper.java +++ b/mens-api/src/main/java/kr/xit/biz/mbl/mapper/IMobilePageMapper.java @@ -3,7 +3,7 @@ package kr.xit.biz.mbl.mapper; import org.egovframe.rte.psl.dataaccess.mapper.Mapper; import kr.xit.biz.ens.model.cntc.CntcDTO; -import kr.xit.biz.ens.model.kakao.v1.KkopayDocDTO; +import kr.xit.biz.mbl.model.MobilePageDTO; import kr.xit.biz.mbl.model.MobilePageDTO.MobilePageManage; /** @@ -24,7 +24,7 @@ import kr.xit.biz.mbl.model.MobilePageDTO.MobilePageManage; @Mapper public interface IMobilePageMapper { // FIXME: kakao v1 or v2 - MobilePageManage selectKkoMobilePage(final KkopayDocDTO.OneTimeToken dto); + MobilePageManage selectKkoMobilePage(final MobilePageDTO.KakaoValidTokenRequest dto); MobilePageManage selectKtMobilePage(final T t); MobilePageManage selectXitMobilePage(final CntcDTO.XitPage dto); } diff --git a/mens-api/src/main/java/kr/xit/biz/mbl/model/MobilePageDTO.java b/mens-api/src/main/java/kr/xit/biz/mbl/model/MobilePageDTO.java index 8b883c4..972320b 100644 --- a/mens-api/src/main/java/kr/xit/biz/mbl/model/MobilePageDTO.java +++ b/mens-api/src/main/java/kr/xit/biz/mbl/model/MobilePageDTO.java @@ -1,9 +1,14 @@ package kr.xit.biz.mbl.model; +import java.time.LocalDateTime; + import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; -import java.time.LocalDateTime; + +import io.swagger.v3.oas.annotations.media.Schema; import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO; import lombok.AllArgsConstructor; import lombok.Data; @@ -64,4 +69,36 @@ public class MobilePageDTO { */ private String register; } + + @Schema(name = "KakaoValidTokenRequest DTO", description = "카카오페이/톡 전자문서 토큰 유효성 검증 파라메터 DTO") + @Data + @SuperBuilder + @NoArgsConstructor + @AllArgsConstructor + @EqualsAndHashCode(callSuper = false) + @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) + public static class KakaoValidTokenRequest { + /** + * 카카오톡 문서 고유 ID정 + */ + private String envelopeId; + /** + * 카카오톡 외부 문서 ID + */ + private String externalId; + + /** + * 카카오페이 문서식별번호 + */ + private String documentBinderUuid; + /** + * 문서 식별 번호(외부 - max:40) + */ + private String externalDocumentUuid; + + /** + * 카카오톡/페이 전자문서 서버에서 생성한 일회용 토큰 : 필수 + */ + private String token; + } } diff --git a/mens-api/src/main/java/kr/xit/biz/mbl/service/IMobilePageService.java b/mens-api/src/main/java/kr/xit/biz/mbl/service/IMobilePageService.java index 2e0848a..9b498e5 100644 --- a/mens-api/src/main/java/kr/xit/biz/mbl/service/IMobilePageService.java +++ b/mens-api/src/main/java/kr/xit/biz/mbl/service/IMobilePageService.java @@ -1,8 +1,8 @@ package kr.xit.biz.mbl.service; import kr.xit.biz.ens.model.cntc.CntcDTO; -import kr.xit.biz.ens.model.kakao.v1.KkopayDocDTO; import kr.xit.biz.ens.model.kt.KtTokenDTO.KtTokenConfirmRequest; +import kr.xit.biz.mbl.model.MobilePageDTO; import kr.xit.core.model.IApiResponse; /** @@ -22,9 +22,10 @@ import kr.xit.core.model.IApiResponse; */ public interface IMobilePageService { // FIXME: kakao v1 or v2 - IApiResponse findKkoMyDocReadyAndMblPage(KkopayDocDTO.OneTimeToken reqDTO); + IApiResponse findKkopayReadyAndMblPage(MobilePageDTO.KakaoValidTokenRequest reqDTO); + IApiResponse findKkotalkReadyAndMblPage(MobilePageDTO.KakaoValidTokenRequest reqDTO); IApiResponse findKtMblPage(final KtTokenConfirmRequest reqDTO); - IApiResponse findXitMyDocReadyAndMblPage(final CntcDTO.XitPage reqDTO); + IApiResponse findXitkkopayReadyAndMblPage(final CntcDTO.XitPage reqDTO); } diff --git a/mens-api/src/main/java/kr/xit/biz/mbl/service/MobilePageService.java b/mens-api/src/main/java/kr/xit/biz/mbl/service/MobilePageService.java index abedeae..97f0b7e 100644 --- a/mens-api/src/main/java/kr/xit/biz/mbl/service/MobilePageService.java +++ b/mens-api/src/main/java/kr/xit/biz/mbl/service/MobilePageService.java @@ -4,9 +4,11 @@ import org.springframework.stereotype.Service; import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.ens.model.kakao.v1.KkopayDocDTO; +import kr.xit.biz.ens.model.kakao.v2.KkotalkApiDTO; import kr.xit.biz.ens.model.kt.KtCommonDTO; import kr.xit.biz.ens.model.kt.KtTokenDTO; import kr.xit.biz.mbl.mapper.IMobilePageMapper; +import kr.xit.biz.mbl.model.MobilePageDTO; import kr.xit.biz.mbl.model.MobilePageDTO.MobilePageManage; import kr.xit.core.consts.ErrorCode; import kr.xit.core.exception.BizRuntimeException; @@ -16,6 +18,7 @@ import kr.xit.core.service.AbstractService; import kr.xit.core.spring.annotation.TraceLogging; import kr.xit.core.support.utils.Checks; import kr.xit.ens.kakao.v1.service.IKkopayEltrcDocService; +import kr.xit.ens.kakao.v2.service.IKkotalkEltrcDocService; import kr.xit.ens.kt.service.IKtBcService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -40,7 +43,8 @@ import lombok.extern.slf4j.Slf4j; @Service public class MobilePageService extends AbstractService implements IMobilePageService { private final IMobilePageMapper mapper; - private final IKkopayEltrcDocService kkoService; + private final IKkopayEltrcDocService kkopayService; + private final IKkotalkEltrcDocService kkotalkService; private final IKtBcService ktMmsService; /** @@ -60,18 +64,62 @@ public class MobilePageService extends AbstractService implements IMobilePageSer */ @Override @TraceLogging - public IApiResponse findKkoMyDocReadyAndMblPage(KkopayDocDTO.OneTimeToken reqDTO) { + public IApiResponse findKkopayReadyAndMblPage(MobilePageDTO.KakaoValidTokenRequest reqDTO) { - if (Checks.isEmpty(reqDTO.getToken()) || Checks.isEmpty(reqDTO.getDocument_binder_uuid()) || Checks.isEmpty(reqDTO.getExternal_document_uuid())) + if (Checks.isEmpty(reqDTO.getToken()) || Checks.isEmpty(reqDTO.getDocumentBinderUuid()) || Checks.isEmpty(reqDTO.getExternalDocumentUuid())) throw BizRuntimeException.create(String.valueOf(ErrorCode.BAD_REQUEST.getHttpStatus().value()), "정상적인 요청이 아닙니다. 재인증 후 시도하시기 바랍니다."); // document_binder_uuid와 external_document_uuid로 데이타 검증 final MobilePageManage mobilePageManage = mapper.selectKkoMobilePage(reqDTO); - if(mobilePageManage == null) throw BizRuntimeException.create("데이타 오류[내문서함 문서가 없습니다]"); + if(mobilePageManage == null) throw BizRuntimeException.create("데이타 오류[카카오페이 내문서함 문서가 없습니다]"); + + final ApiResponseDTO res = kkopayService.findKkopayReadyAndMblPage( + KkopayDocDTO.OneTimeToken.builder() + .document_binder_uuid(reqDTO.getDocumentBinderUuid()) + .external_document_uuid(reqDTO.getExternalDocumentUuid()) + .token(reqDTO.getToken()) + .signguCode(mobilePageManage.getSignguCode()) + .ffnlgCode(mobilePageManage.getFfnlgCode()) + .build() + ); + if(!res.isSuccess()){ + return res; + } + return ApiResponseDTO.success(mobilePageManage.getMobilePageCn()); + } + + /** + *
+     * 카카오 내문서함 모바일 페이지 컨탠트 요청
+     * - 대상 : 문서발송요청(bulks-배치처리)을 통해 document_binder_uuid를 발급 받은 데이타
+     * - 모바일의 redirect url을 통해 들어온 요청 처리
+     *   -> 서버에서 해당 문서에 매핑한 모바일 페이지 내용을 앱에 전달
+     *   -> 카카오페이 > 내문서함 > 문서 클릭시 실행
+     *
+     * 처리 내용
+     * 1. 토큰유효성 검증(redirect url 접속 허용/불허
+     * 2. 문서상태 변경
+     *
+     * @param reqDTO KkopayDocDTO.OneTimeToken
+     * 
+ */ + @Override + @TraceLogging + public IApiResponse findKkotalkReadyAndMblPage(MobilePageDTO.KakaoValidTokenRequest reqDTO) { - reqDTO.setSignguCode(mobilePageManage.getSignguCode()); - reqDTO.setFfnlgCode(mobilePageManage.getFfnlgCode()); + if (Checks.isEmpty(reqDTO.getToken()) || Checks.isEmpty(reqDTO.getEnvelopeId()) || Checks.isEmpty(reqDTO.getExternalId())) + throw BizRuntimeException.create(String.valueOf(ErrorCode.BAD_REQUEST.getHttpStatus().value()), "정상적인 요청이 아닙니다. 재인증 후 시도하시기 바랍니다."); + // document_binder_uuid와 external_document_uuid로 데이타 검증 + final MobilePageManage mobilePageManage = mapper.selectKkoMobilePage(reqDTO); + if(mobilePageManage == null) throw BizRuntimeException.create("데이타 오류[카카오톡 내문서함 문서가 없습니다]"); - final ApiResponseDTO res = kkoService.findMyDocReadyAndMblPage(reqDTO); + final ApiResponseDTO res = kkotalkService.findKkotalkReadyAndMblPage( + KkotalkApiDTO.ValidTokenRequest.builder() + .envelopeId(reqDTO.getEnvelopeId()) + .token(reqDTO.getToken()) + .signguCode(mobilePageManage.getSignguCode()) + .ffnlgCode(mobilePageManage.getFfnlgCode()) + .build() + ); if(!res.isSuccess()){ return res; } @@ -138,7 +186,7 @@ public class MobilePageService extends AbstractService implements IMobilePageSer */ @Override @TraceLogging - public IApiResponse findXitMyDocReadyAndMblPage(final CntcDTO.XitPage reqDTO) { + public IApiResponse findXitkkopayReadyAndMblPage(final CntcDTO.XitPage reqDTO) { // unitySndngDetailId로 데이타 조회 final MobilePageManage mobilePageManage = mapper.selectXitMobilePage(reqDTO); diff --git a/mens-api/src/main/java/kr/xit/biz/mbl/web/MobilePageController.java b/mens-api/src/main/java/kr/xit/biz/mbl/web/MobilePageController.java index 0c5a084..11c18be 100644 --- a/mens-api/src/main/java/kr/xit/biz/mbl/web/MobilePageController.java +++ b/mens-api/src/main/java/kr/xit/biz/mbl/web/MobilePageController.java @@ -14,8 +14,8 @@ import io.swagger.v3.oas.annotations.tags.Tag; import kr.xit.biz.common.ApiConstants; import kr.xit.biz.common.ApiConstants.SignguCode; import kr.xit.biz.ens.model.cntc.CntcDTO; -import kr.xit.biz.ens.model.kakao.v1.KkopayDocDTO; import kr.xit.biz.ens.model.kt.KtTokenDTO; +import kr.xit.biz.mbl.model.MobilePageDTO; import kr.xit.biz.mbl.service.IMobilePageService; import kr.xit.core.model.IApiResponse; import lombok.RequiredArgsConstructor; @@ -38,7 +38,7 @@ import lombok.RequiredArgsConstructor; @Tag(name = "MobilePageController", description = "전자문서 중개자 모바일 페이지 API Controller") @RequiredArgsConstructor @RestController -@RequestMapping(value = "/api/biz/mbl/v1") +@RequestMapping(value = "/api/biz/mbl") public class MobilePageController { private final IMobilePageService service; @@ -52,9 +52,16 @@ public class MobilePageController { * */ @Operation(summary = "카카오 모바일 데이타 요청(모바일 페이지에서 호출)", description = "카카오 모바일 데이타 요청(모바일 페이지에서 호출)") - @PostMapping(value = "/kko/mblPage", produces = MediaType.APPLICATION_JSON_VALUE) - public IApiResponse findKkoMyDocReadyAndMblData(@RequestBody final KkopayDocDTO.OneTimeToken reqDTO) { - return service.findKkoMyDocReadyAndMblPage(reqDTO); + @PostMapping( + value = {"/kkopay/mblPage", "/kkotalk/mblPage"}, produces = MediaType.APPLICATION_JSON_VALUE) + public IApiResponse findKkoMyDocReadyAndMblData(@RequestBody final MobilePageDTO.KakaoValidTokenRequest reqDTO, final HttpServletRequest request) { + final String uri = request.getRequestURI(); + + if(uri.contains("/kkopay/mblPage")) { + return service.findKkopayReadyAndMblPage(reqDTO); + }else{ + return service.findKkotalkReadyAndMblPage(reqDTO); + } } /** @@ -109,6 +116,6 @@ public class MobilePageController { @Operation(summary = "XIT 모바일 데이타 요청(모바일 페이지에서 호출)", description = "XIT 모바일 데이타 요청(모바일 페이지에서 호출)") @PostMapping(value = "/xit/mblPage", produces = MediaType.APPLICATION_JSON_VALUE) public IApiResponse findXitMyDocReadyAndMblData(@RequestBody final CntcDTO.XitPage reqDTO) { - return service.findXitMyDocReadyAndMblPage(reqDTO); + return service.findXitkkopayReadyAndMblPage(reqDTO); } } diff --git a/mens-api/src/main/java/kr/xit/ens/kakao/v1/service/IKkopayEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/v1/service/IKkopayEltrcDocService.java index a645a34..b914b9e 100644 --- a/mens-api/src/main/java/kr/xit/ens/kakao/v1/service/IKkopayEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/v1/service/IKkopayEltrcDocService.java @@ -92,6 +92,6 @@ public interface IKkopayEltrcDocService { KkopayDocBulkDTO.BulkStatusResponses findBulkStatus(final KkopayDocBulkDTO.BulkStatusRequests reqDTO); - ApiResponseDTO findMyDocReadyAndMblPage(KkopayDocDTO.OneTimeToken reqDTO); + ApiResponseDTO findKkopayReadyAndMblPage(KkopayDocDTO.OneTimeToken reqDTO); } diff --git a/mens-api/src/main/java/kr/xit/ens/kakao/v1/service/KkopayEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/v1/service/KkopayEltrcDocService.java index 783f0e5..2d980fd 100644 --- a/mens-api/src/main/java/kr/xit/ens/kakao/v1/service/KkopayEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/v1/service/KkopayEltrcDocService.java @@ -258,7 +258,7 @@ public class KkopayEltrcDocService extends AbstractService implements } @Override - public ApiResponseDTO findMyDocReadyAndMblPage(final KkopayDocDTO.OneTimeToken reqDTO) { + public ApiResponseDTO findKkopayReadyAndMblPage(final KkopayDocDTO.OneTimeToken reqDTO) { final String url = HOST + API_VALID_TOKEN[0].replace(DOCUMENT_BINDER_UUID, reqDTO.getDocument_binder_uuid()) .replace("{tokens}", reqDTO.getToken()); diff --git a/mens-api/src/main/java/kr/xit/ens/kakao/v2/service/IKkotalkEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/v2/service/IKkotalkEltrcDocService.java index 5ba22f2..6dd5f83 100644 --- a/mens-api/src/main/java/kr/xit/ens/kakao/v2/service/IKkotalkEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/v2/service/IKkotalkEltrcDocService.java @@ -90,6 +90,6 @@ public interface IKkotalkEltrcDocService { KkotalkDTO.BulkStatusResponse findBulkStatus(final KkotalkDTO.BulkStatusRequest reqDTO); - ApiResponseDTO findMyDocReadyAndMblPage(KkotalkApiDTO.ValidTokenRequest reqDTO); + ApiResponseDTO findKkotalkReadyAndMblPage(KkotalkApiDTO.ValidTokenRequest reqDTO); } diff --git a/mens-api/src/main/java/kr/xit/ens/kakao/v2/service/KkotalkEltrcDocService.java b/mens-api/src/main/java/kr/xit/ens/kakao/v2/service/KkotalkEltrcDocService.java index 9239327..49f2b80 100644 --- a/mens-api/src/main/java/kr/xit/ens/kakao/v2/service/KkotalkEltrcDocService.java +++ b/mens-api/src/main/java/kr/xit/ens/kakao/v2/service/KkotalkEltrcDocService.java @@ -282,7 +282,7 @@ public class KkotalkEltrcDocService extends AbstractService implements } @Override - public ApiResponseDTO findMyDocReadyAndMblPage(final KkotalkApiDTO.ValidTokenRequest reqDTO) { + public ApiResponseDTO findKkotalkReadyAndMblPage(final KkotalkApiDTO.ValidTokenRequest reqDTO) { final String url = HOST + API_VALID_TOKEN[0].replace(ENVELOPE_ID, reqDTO.getEnvelopeId()) .replace("{TOKEN}", reqDTO.getToken()); diff --git a/mens-api/src/main/resources/egovframework/mapper/biz/ens-mbl-mysql-mapper.xml b/mens-api/src/main/resources/egovframework/mapper/biz/ens-mbl-mysql-mapper.xml index 682aa2c..fc37fd2 100644 --- a/mens-api/src/main/resources/egovframework/mapper/biz/ens-mbl-mysql-mapper.xml +++ b/mens-api/src/main/resources/egovframework/mapper/biz/ens-mbl-mysql-mapper.xml @@ -3,8 +3,8 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + /** ens-mbl-mysql-mapper|selectKkopayMobilePage-카카오페이 모바일 페이지 콘텐트 조회|julim */ SELECT tempm.sndng_detail_id , tempm.sndng_se_code , tempm.mobile_page_cn @@ -17,6 +17,20 @@ AND tekmd.document_binder_uuid = #{document_binder_uuid} + + + /** ens-mbl-oracle-mapper|selectKkopayMobilePage-카카오페이 모바일 페이지 콘텐트 조회|julim */ + SELECT tempm.sndng_detail_id + , tempm.sndng_se_code + , tempm.mobile_page_cn + , tekmd.signgu_code + , tekmd.ffnlg_code + FROM tb_ens_kakao_my_doc tekmd + JOIN tb_ens_mobile_page_manage tempm + ON tekmd.sndng_detail_id = tempm.sndng_detail_id + WHERE tekmd.external_document_uuid = #{external_document_uuid} + AND tekmd.document_binder_uuid = #{document_binder_uuid} + + + + + + + + +