From 12ee3f15993d93fce1334440c66b922fd1afd885 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Thu, 29 Aug 2024 12:21:50 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20kt=20BC/GIBIS=20=EB=AA=A8=EB=B0=94?= =?UTF-8?q?=EC=9D=BC=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A1=B0=ED=9A=8C=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/biz/mbl/mapper/IMobilePageMapper.java | 6 +- .../biz/mbl/service/IMobilePageService.java | 8 +- .../biz/mbl/service/MobilePageService.java | 72 +++++++++++----- .../xit/biz/mbl/web/MobilePageController.java | 82 ++++++++++++------- .../mapper/biz/ens-mbl-mysql-mapper.xml | 26 ++---- .../mapper/biz/ens-mbl-oracle-mapper.xml | 34 ++++---- 6 files changed, 137 insertions(+), 91 deletions(-) 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 1bce069..4b2fe96 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 @@ -2,7 +2,6 @@ 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.mbl.model.MobilePageDTO; import kr.xit.biz.mbl.model.MobilePageDTO.MobilePageManage; @@ -26,6 +25,7 @@ public interface IMobilePageMapper { // FIXME: kakao v1 or v2 MobilePageManage selectKkopayMobilePage(final MobilePageDTO.KakaoValidTokenRequest dto); MobilePageManage selectKkotalkMobilePage(final MobilePageDTO.KakaoValidTokenRequest dto); - MobilePageManage selectKtMobilePage(final T t); - MobilePageManage selectXitMobilePage(final CntcDTO.XitPage dto); + + MobilePageManage selectKtBcMobilePage(final T t); + MobilePageManage selectKtGbsMobilePage(final T t); } 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 836acff..546a43f 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,9 +1,8 @@ package kr.xit.biz.mbl.service; -import kr.xit.biz.ens.model.cntc.CntcDTO; import kr.xit.biz.ens.model.kt.KtTokenDTO.KtTokenConfirmRequest; +import kr.xit.biz.ens.model.ktgbs.KtGbsDTO; import kr.xit.biz.mbl.model.MobilePageDTO; -import kr.xit.core.model.IApiResponse; /** *
@@ -25,7 +24,6 @@ public interface IMobilePageService {
     String findKkopayReadyAndMblPage(MobilePageDTO.KakaoValidTokenRequest reqDTO);
     String findKkotalkReadyAndMblPage(MobilePageDTO.KakaoValidTokenRequest reqDTO);
 
-    IApiResponse findKtMblPage(final KtTokenConfirmRequest reqDTO);
-
-    IApiResponse findXitkkopayReadyAndMblPage(final CntcDTO.XitPage reqDTO);
+    String findKtBcMblPage(final KtTokenConfirmRequest reqDTO);
+    String findKtGbsMblPage(final KtGbsDTO.TokenConfirmRequest 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 1645f38..24e6d3a 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
@@ -2,24 +2,25 @@ package kr.xit.biz.mbl.service;
 
 import org.springframework.stereotype.Service;
 
-import kr.xit.biz.ens.model.cntc.CntcDTO;
 import kr.xit.biz.ens.model.kakao.pay.KkopayDocDTO;
 import kr.xit.biz.ens.model.kakao.talk.KkotalkApiDTO;
 import kr.xit.biz.ens.model.kt.KtCommonDTO;
 import kr.xit.biz.ens.model.kt.KtTokenDTO;
+import kr.xit.biz.ens.model.ktgbs.KtGbsDTO;
 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;
 import kr.xit.core.model.ApiResponseDTO;
-import kr.xit.core.model.IApiResponse;
 import kr.xit.core.service.AbstractService;
 import kr.xit.core.spring.annotation.TraceLogging;
 import kr.xit.core.support.utils.Checks;
+import kr.xit.core.support.utils.DateUtils;
 import kr.xit.ens.kakao.pay.service.IKkopayEltrcDocService;
 import kr.xit.ens.kakao.talk.service.IKkotalkEltrcDocService;
 import kr.xit.ens.kt.service.IKtBcService;
+import kr.xit.ens.ktgbs.service.IKtGbsService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 
@@ -45,7 +46,8 @@ public class MobilePageService extends AbstractService implements IMobilePageSer
     private final IMobilePageMapper mapper;
     private final IKkopayEltrcDocService kkopayService;
     private final IKkotalkEltrcDocService kkotalkService;
-    private final IKtBcService ktMmsService;
+    private final IKtBcService ktBcService;
+    private final IKtGbsService ktGbsService;
 
     /**
      * 
@@ -131,7 +133,7 @@ public class MobilePageService extends AbstractService implements IMobilePageSer
 
     /**
      * 
-     * KT 모바일 페이지 요청 처리
+     * KT BC 모바일 페이지 요청 처리
      * - 본문자 수신 등록 요청(BC-AG-SN-002) API 호출시
      *   -> url(callback)에 등록하여 호출 되게 됨
      *   -> callback url ? token=... 형태로
@@ -146,21 +148,21 @@ public class MobilePageService extends AbstractService implements IMobilePageSer
      */
     @Override
     @TraceLogging
-    public IApiResponse findKtMblPage(final KtTokenDTO.KtTokenConfirmRequest reqDTO) {
+    public String findKtBcMblPage(final KtTokenDTO.KtTokenConfirmRequest reqDTO) {
         //TODO::테스트
         //MobilePageManage mblDTO = mapper.selectKtMobilePage("DPDKT202311080000111");
         //return ApiResponseDTO.success(mblDTO.getMobilePageCn());
 
         //TODO::실운영시 코멘트 제거
         if (Checks.isEmpty(reqDTO.getAccessToken()))
-            throw BizRuntimeException.create(String.valueOf(ErrorCode.BAD_REQUEST.getHttpStatus().value()), "KT 안심문자 정상 요청이 아닙니다. 재인증 후 시도하시기 바랍니다.");
+            throw BizRuntimeException.create(String.valueOf(ErrorCode.BAD_REQUEST.getHttpStatus().value()), "KT BC 안심문자 정상 요청이 아닙니다. 재인증 후 시도하시기 바랍니다.");
 
         final String signguCode = reqDTO.getSignguCode();
         final String ffnlgCode = reqDTO.getFfnlgCode();
-        final KtTokenDTO.KtTokenConfirmResponse cfmRes = ktMmsService.cfmToken(reqDTO);
+        final KtTokenDTO.KtTokenConfirmResponse cfmRes = ktBcService.cfmToken(reqDTO);
 
         if(cfmRes.getResultCd().equals("00")){
-            KtCommonDTO.KtCommonResponse readRes = ktMmsService.readToken(
+            KtCommonDTO.KtCommonResponse readRes = ktBcService.readToken(
                 KtTokenDTO.KtTokenReadRequest.builder()
                     .signguCode(signguCode)
                     .ffnlgCode(ffnlgCode)
@@ -170,8 +172,8 @@ public class MobilePageService extends AbstractService implements IMobilePageSer
 
             if(readRes.getResultCd().equals("00")){
                 String srcKey = cfmRes.getSrcKey();
-                final MobilePageManage mobilePageManage = mapper.selectKtMobilePage(srcKey);
-                return ApiResponseDTO.success(mobilePageManage.getMobilePageCn());
+                final MobilePageManage mobilePageManage = mapper.selectKtBcMobilePage(srcKey);
+                return mobilePageManage.getMobilePageCn();
             }
             throw BizRuntimeException.create(readRes.getResultCd(), readRes.toStringErrorMsg());
         }
@@ -180,21 +182,51 @@ public class MobilePageService extends AbstractService implements IMobilePageSer
 
     /**
      * 
-     * XIT 내문서함 모바일 페이지 컨탠트 요청
-     * - 대상 : unitySndngDetailId를 통해 데이터 조회
-     * - 모바일의 redirect url을 통해 들어온 요청 처리
-     *
-     * @param reqDTO CntcDTO.XitPage
+     * KT GIBIS 모바일 페이지 요청 처리
+     * - 본문자 수신 등록 요청 API 호출시
+     *   -> url(callback)에 등록하여 호출 되게 됨
+     *   -> callback url ? token=... 형태로
+     * 1. 토큰인증확인조회요청 API call
+     * 2. 토큰열람확인결과 전송 API call
+     *    -> srcKey 획득
+     * 3. kt BIBIS 모바일 데이타 조회
+     *    -> return
+     * @param reqDTO KtTokenConfirmRequest
+     * @return
      * 
*/ @Override @TraceLogging - public IApiResponse findXitkkopayReadyAndMblPage(final CntcDTO.XitPage reqDTO) { + public String findKtGbsMblPage(final KtGbsDTO.TokenConfirmRequest reqDTO) { + //TODO::테스트 + //MobilePageManage mblDTO = mapper.selectKtMobilePage("DPDKT202311080000111"); + //return ApiResponseDTO.success(mblDTO.getMobilePageCn()); + + //TODO::실운영시 코멘트 제거 + if (Checks.isEmpty(reqDTO.getToken())) + throw BizRuntimeException.create(String.valueOf(ErrorCode.BAD_REQUEST.getHttpStatus().value()), "KT GIBIS 안심문자 정상 요청이 아닙니다. 재인증 후 시도하시기 바랍니다."); - // unitySndngDetailId로 데이타 조회 - final MobilePageManage mobilePageManage = mapper.selectXitMobilePage(reqDTO); - if(mobilePageManage == null) throw BizRuntimeException.create("데이타 오류[내문서함 문서가 없습니다]"); + final String signguCode = reqDTO.getSignguCode(); + final String ffnlgCode = reqDTO.getFfnlgCode(); + final KtCommonDTO.KtCommonResponse cfmRes = ktGbsService.cfmToken(reqDTO); - return ApiResponseDTO.success(mobilePageManage.getMobilePageCn()); + if(cfmRes.getResultCd().equals("00")){ + KtCommonDTO.KtCommonResponse readRes = ktGbsService.readToken( + KtGbsDTO.TokenReadRequest.builder() + .signguCode(signguCode) + .ffnlgCode(ffnlgCode) + .accessToken(reqDTO.getToken()) + .mmsRdgTmst(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) + .build() + ); + + if(readRes.getResultCd().equals("00")){ + String srcKey = reqDTO.getSrcKey(); + final MobilePageManage mobilePageManage = mapper.selectKtGbsMobilePage(srcKey); + return mobilePageManage.getMobilePageCn(); + } + throw BizRuntimeException.create(readRes.getResultCd(), readRes.toStringErrorMsg()); + } + throw BizRuntimeException.create(cfmRes.getResultCd(), cfmRes.toStringErrorMsg()); } } 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 f9b5b72..0dc9cc7 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 @@ -6,7 +6,6 @@ import org.apache.commons.lang.StringUtils; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.ModelAttribute; 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.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -17,12 +16,11 @@ import io.swagger.v3.oas.annotations.Operation; 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.kt.KtTokenDTO; +import kr.xit.biz.ens.model.ktgbs.KtGbsDTO; import kr.xit.biz.mbl.model.MobilePageDTO; import kr.xit.biz.mbl.service.IMobilePageService; import kr.xit.core.exception.BizRuntimeException; -import kr.xit.core.model.IApiResponse; import lombok.RequiredArgsConstructor; /** @@ -85,6 +83,9 @@ public class MobilePageController { /** *
      * KT 모바일 페이지 요청
+     * /kt/mblPage/old - 기존 모바일 페이지(이전 API 사용 모바일 페이지)
+     * /kt/mblPage/canES - 천안 동남 구철
+     * /kt/mblPage/canWB - 천안 서북 구청
      * - 본문자 수신 등록 요청(BC-AG-SN-002) API 호출시
      *   -> url(callback)에 등록하여 호출 되게 됨
      *   -> callback url ? token=... 형태로
@@ -103,37 +104,56 @@ public class MobilePageController {
      */
     @Operation(summary = "KT 모바일 데이타 요청(모바일 페이지에서 호출)", description = "KT 모바일 데이타 요청(모바일 페이지에서 호출)")
     @PostMapping(
-        value = {"/kt/dpMblPage", "/kt/meMblPage"},
+        value = {"/kt/mblPage/old", "/kt/mblPage/canES", "/kt/mblPage/canWN"},
         produces = MediaType.APPLICATION_JSON_VALUE)
-    public IApiResponse findKtMblPage(@RequestParam final String token, final HttpServletRequest request) {
+    public ModelAndView findKtMblPage(@RequestParam final String token, final HttpServletRequest request) {
         final String uri = request.getRequestURI();
-        //FIXME: KT mblpage 적용 안됨
-        final KtTokenDTO.KtTokenConfirmRequest cfmReqDTO = KtTokenDTO.KtTokenConfirmRequest.builder()
-            .signguCode(SignguCode.CHUNCHEON.getCode())
-            .ffnlgCode(ApiConstants.FFNLN_CODE)
-            .accessToken(token)
-            .build();
+        String mblCnts = "";
 
-        //FIXME: KT mblpage 적용 안됨
-        if(uri.contains("meMblPage")){
-            cfmReqDTO.setSignguCode(SignguCode.CHEONAN_ES.getCode());
-            //cfmReqDTO.setSignguCode(SignguCode.CHEONAN_WN.getCode());
-        }
-        return service.findKtMblPage(cfmReqDTO);
-    }
+        ModelAndView mav = new ModelAndView();
+        mav.setViewName("/notiprnt");
 
-    /**
-     * 
-     *  XIT 모바일 페이지 요청
-     *  - mens-web에서 호출 : {@code EnsInboundApiController.findXitMblPage}
-     *    xit mobile page
-     * @param reqDTO CntcDTO.XitPage
-     * @return IApiResponse 모바일 페이지 데이타 String return
-     * 
- */ - @Operation(summary = "XIT 모바일 데이타 요청(모바일 페이지에서 호출)", description = "XIT 모바일 데이타 요청(모바일 페이지에서 호출)") - @PostMapping(value = "/xit/mblPage", produces = MediaType.APPLICATION_JSON_VALUE) - public IApiResponse findXitMyDocReadyAndMblData(@RequestBody final CntcDTO.XitPage reqDTO) { - return service.findXitkkopayReadyAndMblPage(reqDTO); + try{ + switch (uri) { + case "/kt/mblPage/canES": + mblCnts = service.findKtGbsMblPage( + KtGbsDTO.TokenConfirmRequest.builder() + .signguCode(SignguCode.CHEONAN_ES.getCode()) + .ffnlgCode(ApiConstants.FFNLN_CODE) + .token(token) + .build() + ); + break; + + case "/kt/mblPage/canWN": + mblCnts = service.findKtGbsMblPage( + KtGbsDTO.TokenConfirmRequest.builder() + .signguCode(SignguCode.CHEONAN_WN.getCode()) + .ffnlgCode(ApiConstants.FFNLN_CODE) + .token(token) + .build() + ); + break; + + case "/kt/mblPage/old": + //FIXME: KT mblpage 적용 안됨 + mblCnts = service.findKtBcMblPage( + KtTokenDTO.KtTokenConfirmRequest.builder() + .signguCode("") + .ffnlgCode(ApiConstants.FFNLN_CODE) + .accessToken(token) + .build() + ); + + default: + throw BizRuntimeException.create(String.format("정상적인 요청이 아닙니다. 요청 url을 확인해 주세요.\n(요청 URL: %s)", uri)); + } + mav.addObject("details", mblCnts); + + }catch (Exception e){ + mav.addObject("errCode", e.getMessage()); + mav.addObject("errMsg", e.getMessage()); + } + return mav; } } 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 fc37fd2..ce220c7 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 @@ -31,22 +31,14 @@ AND tekmd.external_id = #{externalId} - - - + /** ens-mbl-mysql-mapper|selectKtBcMobilePage-KT BC 모바일 페이지 콘텐트 조회|julim */ + SELECT tempm.sndng_detail_id + , tempm.sndng_se_code + , tempm.mobile_page_cn + FROM tb_ens_kt_bc_detail tekbd + JOIN tb_ens_mobile_page_manage tempm + ON tekbd.sndng_detail_id = tempm.sndng_detail_id + WHERE tekbd.src_key = #{srcKey} - diff --git a/mens-api/src/main/resources/egovframework/mapper/biz/ens-mbl-oracle-mapper.xml b/mens-api/src/main/resources/egovframework/mapper/biz/ens-mbl-oracle-mapper.xml index 6aa5b49..ae786ce 100644 --- a/mens-api/src/main/resources/egovframework/mapper/biz/ens-mbl-oracle-mapper.xml +++ b/mens-api/src/main/resources/egovframework/mapper/biz/ens-mbl-oracle-mapper.xml @@ -31,22 +31,26 @@ AND tekmd.external_id = #{externalId} - + /** ens-mbl-oracle-mapper|selectKtBcMobilePage-KT BC 모바일 페이지 콘텐트 조회|julim */ + SELECT tempm.sndng_detail_id + , tempm.sndng_se_code + , tempm.mobile_page_cn + FROM tb_ens_kt_bc_detail tekbd + JOIN tb_ens_mobile_page_manage tempm + ON tekbd.sndng_detail_id = tempm.sndng_detail_id + WHERE tekbd.src_key = #{srcKey} - +