feat: KT API 반영

dev
gitea-관리자 1 year ago
parent 49e7cc4210
commit f2f3237b91

@ -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.CmmEnsRequestDTO;
import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; 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 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; import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
/** /**
@ -26,5 +25,5 @@ import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
@Mapper @Mapper
public interface ICmmEnsCacheMapper { public interface ICmmEnsCacheMapper {
NiceCiInfo selectNiceCiInfo(final NiceCiRequest dto); NiceCiInfo selectNiceCiInfo(final NiceCiRequest dto);
<T> CmmEnsRlaybsnmDTO selectEnsRlaybsnmInfo(final T t); CmmEnsRlaybsnmDTO selectEnsRlaybsnmInfo(final CmmEnsRequestDTO dto);
} }

@ -5,20 +5,17 @@ import com.github.benmanes.caffeine.cache.stats.CacheStats;
import kr.xit.biz.cmm.mapper.ICmmEnsCacheMapper; import kr.xit.biz.cmm.mapper.ICmmEnsCacheMapper;
import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO; import kr.xit.biz.ens.model.cmm.CmmEnsRequestDTO;
import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; 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.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.CacheKeyGenerator;
import kr.xit.core.spring.config.cache.CachingConfig;
import kr.xit.core.spring.config.cache.CacheType; import kr.xit.core.spring.config.cache.CacheType;
import kr.xit.core.spring.config.cache.CachingConfig;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.caffeine.CaffeineCache; import org.springframework.cache.caffeine.CaffeineCache;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -77,8 +74,8 @@ public class CmmEnsCacheService implements ICmmEnsCacheService {
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Cacheable(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator") @Cacheable(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator")
public <T> CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final T t) { public CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final CmmEnsRequestDTO dto) {
return cmmEnsMapper.selectEnsRlaybsnmInfo(t); return cmmEnsMapper.selectEnsRlaybsnmInfo(dto);
} }
/** /**
@ -88,7 +85,7 @@ public class CmmEnsCacheService implements ICmmEnsCacheService {
*/ */
@Transactional(readOnly = true) @Transactional(readOnly = true)
@CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator") @CacheEvict(cacheNames = "rlaybsnmInfo", keyGenerator = "cacheKeyGenerator")
public <T> 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()) { for(String cacheName : cacheManager.getCacheNames()) {
Cache cache = ((CaffeineCache) cacheManager.getCache(cacheName)).getNativeCache(); Cache cache = ((CaffeineCache) cacheManager.getCache(cacheName)).getNativeCache();
// for(Object key : cache.asMap().keySet()) { for(Object key : cache.asMap().keySet()) {
// Object value = cache.getIfPresent(key); Object value = cache.getIfPresent(key);
// log.info("key: {} - value: {}", key, value.toString()); log.info("key: {}", key);
// } //log.info("key: {} - value: {}", key, value.toString());
}
CacheStats stats = cache.stats(); CacheStats stats = cache.stats();
log.info("cache '{}' - stats : {}", cacheName, stats.toString()); log.info("cache '{}' - stats : {}", cacheName, stats.toString());

@ -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.CmmEnsRequestDTO;
import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; 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.NiceCiInfo;
import org.apache.poi.ss.formula.functions.T; import kr.xit.biz.ens.model.nice.NiceCiDTO.NiceCiRequest;
/** /**
* <pre> * <pre>
@ -26,8 +24,8 @@ public interface ICmmEnsCacheService {
NiceCiInfo getNiceCiInfoCache(final NiceCiRequest dto); NiceCiInfo getNiceCiInfoCache(final NiceCiRequest dto);
void removeNiceCiInfoCache(final NiceCiRequest dto); void removeNiceCiInfoCache(final NiceCiRequest dto);
<T> CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final T t); CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final CmmEnsRequestDTO dto);
<T> void removeRlaybsnmInfoCache(final T t); void removeRlaybsnmInfoCache(final CmmEnsRequestDTO dto);
void logCache(); void logCache();
} }

@ -10,7 +10,6 @@ import kr.xit.core.spring.util.CoreSpringUtils;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.ss.formula.functions.T;
/** /**
* <pre> * <pre>
@ -37,12 +36,12 @@ public class CmmKakaoUtils {
* KT MMS * KT MMS
* @return * @return
*/ */
public static <T> CmmEnsRlaybsnmDTO getRlaybsnmInfo(T t) { public static CmmEnsRlaybsnmDTO getRlaybsnmInfo(final CmmEnsRequestDTO dto) {
final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(t); final CmmEnsRlaybsnmDTO ensDTO = cacheService.getRlaybsnmInfoCache(dto);
if(ObjectUtils.isEmpty(dto)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info")); if(ObjectUtils.isEmpty(dto)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info"));
cacheService.logCache(); cacheService.logCache();
return dto; return ensDTO;
} }

@ -2,6 +2,7 @@ package kr.xit.ens.kt.cmm;
import egovframework.com.cmm.EgovMessageSource; import egovframework.com.cmm.EgovMessageSource;
import kr.xit.biz.cmm.service.ICmmEnsCacheService; 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.cmm.CmmEnsRlaybsnmDTO;
import kr.xit.biz.ens.model.kt.KtCommonDTO.KtMnsRequest; import kr.xit.biz.ens.model.kt.KtCommonDTO.KtMnsRequest;
import kr.xit.core.exception.BizRuntimeException; import kr.xit.core.exception.BizRuntimeException;
@ -42,13 +43,13 @@ public class CmmKtMmsUtils {
* @return * @return
*/ */
public static CmmEnsRlaybsnmDTO getRlaybsnmInfo(final String signguCode, final String ffnlgCode) { public static CmmEnsRlaybsnmDTO getRlaybsnmInfo(final String signguCode, final String ffnlgCode) {
KtMnsRequest ktReqDTO = KtMnsRequest.builder() CmmEnsRequestDTO ensDTO = CmmEnsRequestDTO.builder()
.signguCode(signguCode) .signguCode(signguCode)
.ffnlgCode(ffnlgCode) .ffnlgCode(ffnlgCode)
.profile(profile) .profile(profile)
.build(); .build();
final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(ktReqDTO); final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(ensDTO);
cacheService.logCache(); cacheService.logCache();
if(ObjectUtils.isEmpty(dto)) throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info")); 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; if(DateUtils.getTodayAndNowTime("yyyy-MM-dd HH:mm:ss").compareTo(dto.getKtTokenExpiresIn()) < 0) return dto;
ktMmsService.requestToken(ktReqDTO); ktMmsService.requestToken(
return cacheService.getRlaybsnmInfoCache(ktReqDTO); KtMnsRequest.builder()
.signguCode(signguCode)
.ffnlgCode(ffnlgCode)
.profile(profile)
.build()
);
return cacheService.getRlaybsnmInfoCache(ensDTO);
} }

@ -184,9 +184,9 @@ public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsServi
@Override @Override
public KtCommonResponse beforeSend(final KtBefSendRequest reqDTO) { public KtCommonResponse beforeSend(final KtBefSendRequest reqDTO) {
final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());
//reqDTO.setServiceCd(ktMnsInfo.get);
//reqDTO.setServiceKey(ktMnsInfo.get);
reqDTO.setServiceCd(ktMnsInfo.getKtServiceCode()); reqDTO.setServiceCd(ktMnsInfo.getKtServiceCode());
reqDTO.setServiceKey(ktMnsInfo.getKtSvcCerfKey());
reqDTO.setSignguCode(null); reqDTO.setSignguCode(null);
reqDTO.setFfnlgCode(null); reqDTO.setFfnlgCode(null);
reqDTO.setProfile(null); reqDTO.setProfile(null);
@ -217,6 +217,7 @@ public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsServi
//reqDTO.setServiceCd(ktMnsInfo.get); //reqDTO.setServiceCd(ktMnsInfo.get);
//reqDTO.setServiceKey(ktMnsInfo.get); //reqDTO.setServiceKey(ktMnsInfo.get);
reqDTO.setServiceCd(ktMnsInfo.getKtServiceCode()); reqDTO.setServiceCd(ktMnsInfo.getKtServiceCode());
reqDTO.setServiceKey(ktMnsInfo.getKtSvcCerfKey());
reqDTO.setSignguCode(null); reqDTO.setSignguCode(null);
reqDTO.setFfnlgCode(null); reqDTO.setFfnlgCode(null);
reqDTO.setProfile(null); reqDTO.setProfile(null);

@ -47,13 +47,12 @@
kt_client_tp, /* KT client tp */ kt_client_tp, /* KT client tp */
kt_scope, /* KT scope */ kt_scope, /* KT scope */
kt_service_code, /* KT service code */ 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_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 secret */ 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 secret */ IF(#{profile} = 'prod', kt_prod_service_cerf_key, kt_dev_service_cerf_key) AS ktSvcCerfKey, /* KT client service cerf key */
kt_access_token, /* KT access token */ IF(#{profile} = 'prod', kt_prod_access_token, kt_dev_access_token) AS ktAccessToken, /* KT access token */
kt_company_cd, /* KT company code */ DATE_ADD(NOW(), INTERVAL IF(#{profile} = 'prod', kt_prod_token_expires_in, kt_dev_token_expires_in) - 86400 SECOND) AS ktTokenExpiresIn, /* KT 토큰 유효기간 : (7775999)(90일) */
DATE_ADD(NOW(), INTERVAL kt_token_expires_in - 86400 SECOND) AS ktTokenExpiresIn, /* KT 토큰 유효기간 : (7775999)(90일) */ IF(#{profile} = 'prod', kt_prod_token_jti, kt_dev_token_jti) AS ktTokenJti, /* KT 토큰 식별자 */
kt_token_jti, /* KT 토큰 식별자 */
epost_service_key, /* epost service key */ epost_service_key, /* epost service key */
pplus_api_key, /* postplus api key */ pplus_api_key, /* postplus api key */
sender_nm, /* 발송인 명 */ sender_nm, /* 발송인 명 */

@ -6,10 +6,19 @@
<update id="updateRlaybsnmKtInfo" parameterType="kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO"> <update id="updateRlaybsnmKtInfo" parameterType="kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO">
/** ens-kt-mysql-mapper|updateRlaybsnmKtInfo-kt token 정보 갱신|julim */ /** ens-kt-mysql-mapper|updateRlaybsnmKtInfo-kt token 정보 갱신|julim */
UPDATE tb_ens_rlaybsnm_manage UPDATE tb_ens_rlaybsnm_manage
SET kt_access_token = #{ktAccessToken}, SET kt_scope = #{ktScope},
kt_token_expires_in = #{ktTokenExpiresIn}, <choose>
kt_token_jti = #{ktTokenJti}, <when test="profile eq 'prod'">
kt_scope = #{ktScope}, kt_prod_access_token = #{ktAccessToken},
kt_prod_token_expires_in = #{ktTokenExpiresIn},
kt_prod_token_jti = #{ktTokenJti},
</when>
<otherwise>
kt_dev_access_token = #{ktAccessToken},
kt_dev_token_expires_in = #{ktTokenExpiresIn},
kt_dev_token_jti = #{ktTokenJti},
</otherwise>
</choose>
updt_dt = now(), updt_dt = now(),
updusr = 'api-biz' updusr = 'api-biz'
WHERE signgu_code = #{signguCode} WHERE signgu_code = #{signguCode}

@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode; import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import java.io.Serializable;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -31,8 +30,8 @@ import lombok.experimental.SuperBuilder;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@SuperBuilder @SuperBuilder
@JsonInclude(Include.NON_ABSENT) @JsonInclude(Include.NON_NULL)
public class CmmEnsRequestDTO implements Serializable { public class CmmEnsRequestDTO {
/** /**
* *

@ -98,10 +98,7 @@ public class CmmEnsRlaybsnmDTO extends AuditFields implements Serializable {
* KT_ACCESS_TOKEN * KT_ACCESS_TOKEN
*/ */
private String ktAccessToken; private String ktAccessToken;
/**
* KT COMPANY CD
*/
private String ktCompanyCd;
/** /**
* KT * KT
*/ */

Loading…
Cancel
Save