From f2f3237b91bd813cf770a4d91791c2586866b312 Mon Sep 17 00:00:00 2001 From: limju Date: Thu, 12 Oct 2023 16:30:20 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20KT=20API=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/cmm/mapper/ICmmEnsCacheMapper.java | 5 ++--- .../biz/cmm/service/CmmEnsCacheService.java | 22 +++++++++---------- .../biz/cmm/service/ICmmEnsCacheService.java | 8 +++---- .../kr/xit/ens/kakao/cmm/CmmKakaoUtils.java | 7 +++--- .../java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java | 15 +++++++++---- .../kr/xit/ens/kt/service/KtMmsService.java | 5 +++-- .../mapper/biz/ens-cmm-cache-mysql-mapper.xml | 13 +++++------ .../mapper/biz/ens-kt-mysql-mapper.xml | 17 ++++++++++---- .../biz/ens/model/cmm/CmmEnsRequestDTO.java | 5 ++--- .../biz/ens/model/cmm/CmmEnsRlaybsnmDTO.java | 5 +---- 10 files changed, 54 insertions(+), 48 deletions(-) diff --git a/mens-api/src/main/java/kr/xit/biz/cmm/mapper/ICmmEnsCacheMapper.java b/mens-api/src/main/java/kr/xit/biz/cmm/mapper/ICmmEnsCacheMapper.java index 68a697d..9fd9a77 100644 --- a/mens-api/src/main/java/kr/xit/biz/cmm/mapper/ICmmEnsCacheMapper.java +++ b/mens-api/src/main/java/kr/xit/biz/cmm/mapper/ICmmEnsCacheMapper.java @@ -2,9 +2,8 @@ package kr.xit.biz.cmm.mapper; import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO; import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; -import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo; -import org.apache.poi.ss.formula.functions.T; +import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import org.egovframe.rte.psl.dataaccess.mapper.Mapper; /** @@ -26,5 +25,5 @@ import org.egovframe.rte.psl.dataaccess.mapper.Mapper; @Mapper public interface ICmmEnsCacheMapper { NiceCiInfo selectNiceCiInfo(final NiceCiRequest dto); - CmmEnsRlaybsnmDTO selectEnsRlaybsnmInfo(final T t); + CmmEnsRlaybsnmDTO selectEnsRlaybsnmInfo(final CmmEnsRequestDTO dto); } diff --git a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java index 6b29b04..997dfa5 100644 --- a/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java +++ b/mens-api/src/main/java/kr/xit/biz/cmm/service/CmmEnsCacheService.java @@ -5,20 +5,17 @@ import com.github.benmanes.caffeine.cache.stats.CacheStats; import kr.xit.biz.cmm.mapper.ICmmEnsCacheMapper; import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO; import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; -import kr.xit.biz.ens.model.nice.NiceCiDTO; -import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo; +import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import kr.xit.core.spring.config.cache.CacheKeyGenerator; -import kr.xit.core.spring.config.cache.CachingConfig; import kr.xit.core.spring.config.cache.CacheType; +import kr.xit.core.spring.config.cache.CachingConfig; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.poi.ss.formula.functions.T; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.caffeine.CaffeineCache; -import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -77,8 +74,8 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { */ @Transactional(readOnly = true) @Cacheable(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator") - public CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final T t) { - return cmmEnsMapper.selectEnsRlaybsnmInfo(t); + public CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final CmmEnsRequestDTO dto) { + return cmmEnsMapper.selectEnsRlaybsnmInfo(dto); } /** @@ -88,7 +85,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { */ @Transactional(readOnly = true) @CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator") - public void removeRlaybsnmInfoCache(final T t) { + public void removeRlaybsnmInfoCache(final CmmEnsRequestDTO dto) { } /** @@ -99,10 +96,11 @@ public class CmmEnsCacheService implements ICmmEnsCacheService { for(String cacheName : cacheManager.getCacheNames()) { Cache cache = ((CaffeineCache) cacheManager.getCache(cacheName)).getNativeCache(); -// for(Object key : cache.asMap().keySet()) { -// Object value = cache.getIfPresent(key); -// log.info("key: {} - value: {}", key, value.toString()); -// } + for(Object key : cache.asMap().keySet()) { + Object value = cache.getIfPresent(key); + log.info("key: {}", key); + //log.info("key: {} - value: {}", key, value.toString()); + } CacheStats stats = cache.stats(); log.info("cache '{}' - stats : {}", cacheName, stats.toString()); diff --git a/mens-api/src/main/java/kr/xit/biz/cmm/service/ICmmEnsCacheService.java b/mens-api/src/main/java/kr/xit/biz/cmm/service/ICmmEnsCacheService.java index d4a3b97..ea8d2e4 100644 --- a/mens-api/src/main/java/kr/xit/biz/cmm/service/ICmmEnsCacheService.java +++ b/mens-api/src/main/java/kr/xit/biz/cmm/service/ICmmEnsCacheService.java @@ -2,10 +2,8 @@ package kr.xit.biz.cmm.service; import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO; import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; -import kr.xit.biz.ens.model.nice.NiceCiDTO; -import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiInfo; -import org.apache.poi.ss.formula.functions.T; +import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest; /** *
@@ -26,8 +24,8 @@ public interface ICmmEnsCacheService {
     NiceCiInfo getNiceCiInfoCache(final NiceCiRequest dto);
     void removeNiceCiInfoCache(final NiceCiRequest dto);
 
-     CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final T t);
-     void removeRlaybsnmInfoCache(final T t);
+    CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final CmmEnsRequestDTO dto);
+    void removeRlaybsnmInfoCache(final CmmEnsRequestDTO dto);
 
     void logCache();
 }
diff --git a/mens-api/src/main/java/kr/xit/ens/kakao/cmm/CmmKakaoUtils.java b/mens-api/src/main/java/kr/xit/ens/kakao/cmm/CmmKakaoUtils.java
index 46608aa..1151f4a 100644
--- a/mens-api/src/main/java/kr/xit/ens/kakao/cmm/CmmKakaoUtils.java
+++ b/mens-api/src/main/java/kr/xit/ens/kakao/cmm/CmmKakaoUtils.java
@@ -10,7 +10,6 @@ import kr.xit.core.spring.util.CoreSpringUtils;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.commons.lang3.ObjectUtils;
-import org.apache.poi.ss.formula.functions.T;
 
 /**
  * 
@@ -37,12 +36,12 @@ public class CmmKakaoUtils {
      * KT MMS 인증 정보 조회
      * @return
      */
-    public static  CmmEnsRlaybsnmDTO getRlaybsnmInfo(T t) {
-        final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(t);
+    public static CmmEnsRlaybsnmDTO getRlaybsnmInfo(final CmmEnsRequestDTO dto) {
+        final CmmEnsRlaybsnmDTO ensDTO = cacheService.getRlaybsnmInfoCache(dto);
         if(ObjectUtils.isEmpty(dto))   throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info"));
         cacheService.logCache();
 
-        return dto;
+        return ensDTO;
     }
 
 
diff --git a/mens-api/src/main/java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java b/mens-api/src/main/java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java
index 36814aa..73ba04c 100644
--- a/mens-api/src/main/java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java
+++ b/mens-api/src/main/java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java
@@ -2,6 +2,7 @@ package kr.xit.ens.kt.cmm;
 
 import egovframework.com.cmm.EgovMessageSource;
 import kr.xit.biz.cmm.service.ICmmEnsCacheService;
+import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
 import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO;
 import kr.xit.biz.ens.model.kt.KtCommonDTO.KtMnsRequest;
 import kr.xit.core.exception.BizRuntimeException;
@@ -42,13 +43,13 @@ public class CmmKtMmsUtils {
      * @return
      */
     public static CmmEnsRlaybsnmDTO getRlaybsnmInfo(final String signguCode, final String ffnlgCode) {
-        KtMnsRequest ktReqDTO = KtMnsRequest.builder()
+        CmmEnsRequestDTO ensDTO = CmmEnsRequestDTO.builder()
             .signguCode(signguCode)
             .ffnlgCode(ffnlgCode)
             .profile(profile)
             .build();
 
-        final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(ktReqDTO);
+        final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(ensDTO);
         cacheService.logCache();
 
         if(ObjectUtils.isEmpty(dto))   throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info"));
@@ -56,8 +57,14 @@ public class CmmKtMmsUtils {
         // 토큰 유효기간 체크
         if(DateUtils.getTodayAndNowTime("yyyy-MM-dd HH:mm:ss").compareTo(dto.getKtTokenExpiresIn()) < 0)     return dto;
 
-        ktMmsService.requestToken(ktReqDTO);
-        return cacheService.getRlaybsnmInfoCache(ktReqDTO);
+        ktMmsService.requestToken(
+            KtMnsRequest.builder()
+                .signguCode(signguCode)
+                .ffnlgCode(ffnlgCode)
+                .profile(profile)
+                .build()
+        );
+        return cacheService.getRlaybsnmInfoCache(ensDTO);
     }
 
 
diff --git a/mens-api/src/main/java/kr/xit/ens/kt/service/KtMmsService.java b/mens-api/src/main/java/kr/xit/ens/kt/service/KtMmsService.java
index cd26cfc..fb80fb7 100644
--- a/mens-api/src/main/java/kr/xit/ens/kt/service/KtMmsService.java
+++ b/mens-api/src/main/java/kr/xit/ens/kt/service/KtMmsService.java
@@ -184,9 +184,9 @@ public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsServi
     @Override
     public KtCommonResponse beforeSend(final KtBefSendRequest reqDTO) {
         final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());
-        //reqDTO.setServiceCd(ktMnsInfo.get);
-        //reqDTO.setServiceKey(ktMnsInfo.get);
+
         reqDTO.setServiceCd(ktMnsInfo.getKtServiceCode());
+        reqDTO.setServiceKey(ktMnsInfo.getKtSvcCerfKey());
         reqDTO.setSignguCode(null);
         reqDTO.setFfnlgCode(null);
         reqDTO.setProfile(null);
@@ -217,6 +217,7 @@ public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsServi
         //reqDTO.setServiceCd(ktMnsInfo.get);
         //reqDTO.setServiceKey(ktMnsInfo.get);
         reqDTO.setServiceCd(ktMnsInfo.getKtServiceCode());
+        reqDTO.setServiceKey(ktMnsInfo.getKtSvcCerfKey());
         reqDTO.setSignguCode(null);
         reqDTO.setFfnlgCode(null);
         reqDTO.setProfile(null);
diff --git a/mens-api/src/main/resources/egovframework/mapper/biz/ens-cmm-cache-mysql-mapper.xml b/mens-api/src/main/resources/egovframework/mapper/biz/ens-cmm-cache-mysql-mapper.xml
index f7144d7..bf89620 100644
--- a/mens-api/src/main/resources/egovframework/mapper/biz/ens-cmm-cache-mysql-mapper.xml
+++ b/mens-api/src/main/resources/egovframework/mapper/biz/ens-cmm-cache-mysql-mapper.xml
@@ -47,13 +47,12 @@
            kt_client_tp,            /* KT client tp */
            kt_scope,                /* KT scope */
            kt_service_code,         /* KT service code */
-           IF(#{profile} = 'prod', kt_prod_client_id, kt_dev_client_id) AS ktSvcClientId,                   /* KT client secret */
-           IF(#{profile} = 'prod', kt_prod_client_secret, kt_dev_client_secret) AS ktSvcClientSecret,       /* KT client secret */
-           IF(#{profile} = 'prod', kt_prod_service_cerf_key, kt_dev_service_cerf_key) AS ktSvcCerfKey,      /* KT client secret */
-           kt_access_token,         /* KT access token */
-           kt_company_cd,           /* KT company code */
-           DATE_ADD(NOW(), INTERVAL kt_token_expires_in - 86400 SECOND) AS ktTokenExpiresIn,     /* KT 토큰 유효기간 : (7775999)(90일) */
-           kt_token_jti,            /* KT 토큰 식별자 */
+           IF(#{profile} = 'prod', kt_prod_client_id, kt_dev_client_id) AS ktSvcClientId,                   /* KT client service ID */
+           IF(#{profile} = 'prod', kt_prod_client_secret, kt_dev_client_secret) AS ktSvcClientSecret,       /* KT client service secret */
+           IF(#{profile} = 'prod', kt_prod_service_cerf_key, kt_dev_service_cerf_key) AS ktSvcCerfKey,      /* KT client service cerf key */
+           IF(#{profile} = 'prod', kt_prod_access_token, kt_dev_access_token) AS ktAccessToken,            /* KT access token */
+           DATE_ADD(NOW(), INTERVAL IF(#{profile} = 'prod', kt_prod_token_expires_in, kt_dev_token_expires_in) - 86400 SECOND) AS ktTokenExpiresIn,     /* KT 토큰 유효기간 : (7775999)(90일) */
+           IF(#{profile} = 'prod', kt_prod_token_jti, kt_dev_token_jti) AS ktTokenJti,            /* KT 토큰 식별자 */
            epost_service_key,       /* epost service key */
            pplus_api_key,           /* postplus api key */
            sender_nm,               /* 발송인 명 */
diff --git a/mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml b/mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml
index 0880b65..cee7836 100644
--- a/mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml
+++ b/mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml
@@ -6,10 +6,19 @@
   
     /** ens-kt-mysql-mapper|updateRlaybsnmKtInfo-kt token 정보 갱신|julim  */
     UPDATE tb_ens_rlaybsnm_manage
-       SET kt_access_token = #{ktAccessToken},
-           kt_token_expires_in = #{ktTokenExpiresIn},
-           kt_token_jti = #{ktTokenJti},
-           kt_scope = #{ktScope},
+       SET kt_scope = #{ktScope},
+           
+             
+               kt_prod_access_token = #{ktAccessToken},
+               kt_prod_token_expires_in = #{ktTokenExpiresIn},
+               kt_prod_token_jti = #{ktTokenJti},
+             
+             
+               kt_dev_access_token = #{ktAccessToken},
+               kt_dev_token_expires_in = #{ktTokenExpiresIn},
+               kt_dev_token_jti = #{ktTokenJti},
+             
+           
            updt_dt = now(),
            updusr = 'api-biz'
      WHERE signgu_code = #{signguCode}
diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsRequestDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsRequestDTO.java
index b92a186..8ba1880 100644
--- a/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsRequestDTO.java
+++ b/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsRequestDTO.java
@@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
-import java.io.Serializable;
 import javax.validation.constraints.Size;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -31,8 +30,8 @@ import lombok.experimental.SuperBuilder;
 @NoArgsConstructor
 @AllArgsConstructor
 @SuperBuilder
-@JsonInclude(Include.NON_ABSENT)
-public class CmmEnsRequestDTO implements Serializable {
+@JsonInclude(Include.NON_NULL)
+public class CmmEnsRequestDTO {
 
     /**
      * 시군구 코드
diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsRlaybsnmDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsRlaybsnmDTO.java
index 72b7738..b0fd915 100644
--- a/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsRlaybsnmDTO.java
+++ b/mens-core/src/main/java/kr/xit/biz/ens/model/cmm/CmmEnsRlaybsnmDTO.java
@@ -98,10 +98,7 @@ public class CmmEnsRlaybsnmDTO extends AuditFields implements Serializable {
      * KT_ACCESS_TOKEN
      */
     private String ktAccessToken;
-    /**
-     * KT COMPANY CD
-     */
-    private String ktCompanyCd;
+
     /**
      * KT 토큰 유효 기간
      */