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.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);
<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.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 <T> 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 <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()) {
Cache cache = ((CaffeineCache) cacheManager.getCache(cacheName)).getNativeCache();
// for(Object key : cache.asMap().keySet()) {
// Object value = cache.getIfPresent(key);
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());

@ -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;
/**
* <pre>
@ -26,8 +24,8 @@ public interface ICmmEnsCacheService {
NiceCiInfo getNiceCiInfoCache(final NiceCiRequest dto);
void removeNiceCiInfoCache(final NiceCiRequest dto);
<T> CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final T t);
<T> void removeRlaybsnmInfoCache(final T t);
CmmEnsRlaybsnmDTO getRlaybsnmInfoCache(final CmmEnsRequestDTO dto);
void removeRlaybsnmInfoCache(final CmmEnsRequestDTO dto);
void logCache();
}

@ -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;
/**
* <pre>
@ -37,12 +36,12 @@ public class CmmKakaoUtils {
* KT MMS
* @return
*/
public static <T> 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;
}

@ -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);
}

@ -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);

@ -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, /* 발송인 명 */

@ -6,10 +6,19 @@
<update id="updateRlaybsnmKtInfo" parameterType="kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO">
/** 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},
<choose>
<when test="profile eq 'prod'">
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(),
updusr = 'api-biz'
WHERE signgu_code = #{signguCode}

@ -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 {
/**
*

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

Loading…
Cancel
Save