From 49e7cc42107ab794efdc48930876207f4bdeba5d Mon Sep 17 00:00:00 2001 From: limju Date: Thu, 12 Oct 2023 14:55:15 +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 --- .../kr/xit/biz/kt/mapper/IBizKtMmsMapper.java | 24 ++ .../xit/biz/kt/service/BizKtMmsService.java | 332 ++++++++++++++++++ .../xit/biz/kt/service/IBizKtMmsService.java | 45 +++ .../kr/xit/biz/kt/web/BizKtMmsController.java | 186 ++++++++++ .../xit/core/spring/util/ApiSpringUtils.java | 7 +- .../java/kr/xit/ens/kt/cmm/CmmKtMmsUtils.java | 32 +- .../kr/xit/ens/kt/service/KtMmsService.java | 38 +- .../kr/xit/ens/kt/web/KtMmsController.java | 24 +- .../xit/ens/pplus/service/PplusService.java | 2 +- .../mapper/biz/ens-cmm-cache-mysql-mapper.xml | 2 +- .../mapper/biz/ens-kt-mysql-mapper.xml | 21 ++ .../messages/message-api.properties | 1 + .../biz/ens/model/cmm/CmmEnsRlaybsnmDTO.java | 4 + .../kr/xit/biz/ens/model/kt/KtMmsSendDTO.java | 7 +- .../config/support/WebClientConfig.java | 4 +- .../core/spring/util/ApiWebClientUtil.java | 205 +++++------ .../kr/xit/core/support/utils/JsonUtils.java | 19 + 17 files changed, 776 insertions(+), 177 deletions(-) create mode 100644 mens-api/src/main/java/kr/xit/biz/kt/mapper/IBizKtMmsMapper.java create mode 100644 mens-api/src/main/java/kr/xit/biz/kt/service/BizKtMmsService.java create mode 100644 mens-api/src/main/java/kr/xit/biz/kt/service/IBizKtMmsService.java create mode 100644 mens-api/src/main/java/kr/xit/biz/kt/web/BizKtMmsController.java create mode 100644 mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml diff --git a/mens-api/src/main/java/kr/xit/biz/kt/mapper/IBizKtMmsMapper.java b/mens-api/src/main/java/kr/xit/biz/kt/mapper/IBizKtMmsMapper.java new file mode 100644 index 0000000..2f4bc9b --- /dev/null +++ b/mens-api/src/main/java/kr/xit/biz/kt/mapper/IBizKtMmsMapper.java @@ -0,0 +1,24 @@ +package kr.xit.biz.kt.mapper; + +import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; +import org.egovframe.rte.psl.dataaccess.mapper.Mapper; + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.biz.kt.mapper
+ * fileName    : IBizKtMmsMapper
+ * author      : limju
+ * date        : 2023-10-12
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2023-10-12    limju       최초 생성
+ *
+ * 
+ */ +@Mapper +public interface IBizKtMmsMapper { + int updateRlaybsnmKtInfo(final CmmEnsRlaybsnmDTO dto); +} diff --git a/mens-api/src/main/java/kr/xit/biz/kt/service/BizKtMmsService.java b/mens-api/src/main/java/kr/xit/biz/kt/service/BizKtMmsService.java new file mode 100644 index 0000000..c501515 --- /dev/null +++ b/mens-api/src/main/java/kr/xit/biz/kt/service/BizKtMmsService.java @@ -0,0 +1,332 @@ +package kr.xit.biz.kt.service; + +import kr.xit.biz.cmm.service.ICmmEnsCacheService; +import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO; +import kr.xit.biz.ens.model.kt.KtCommonDTO.KtMnsRequest; +import kr.xit.biz.ens.model.kt.KtTokenDTO.KtTokenResponse; +import kr.xit.biz.kt.mapper.IBizKtMmsMapper; +import kr.xit.core.exception.BizRuntimeException; +import kr.xit.ens.kt.service.IKtMmsService; +import lombok.RequiredArgsConstructor; +import org.apache.commons.lang3.StringUtils; +import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; +import org.springframework.stereotype.Service; + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.biz.kt.service
+ * fileName    : BizKtMmsService
+ * author      : limju
+ * date        : 2023-09-22
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2023-09-22    limju       최초 생성
+ *
+ * 
+ */ +@RequiredArgsConstructor +@Service +public class BizKtMmsService extends EgovAbstractServiceImpl implements IBizKtMmsService { + private static final String profile = System.getProperty("spring.profiles.active"); + + private final IKtMmsService ktMmsService; + private final ICmmEnsCacheService cacheService; + private final IBizKtMmsMapper mapper; + + /** + * kt Access token 획득 + * 1. kt Access token 요청 + * 2. 요청결과 DB 반영 + * 3. 정보중계자 정보 캐시 삭제 + * @param paramDTO + * @return + */ + @Override + public KtTokenResponse requestToken(final KtMnsRequest paramDTO) { + KtTokenResponse resDTO = ktMmsService.requestToken(paramDTO); + + if(StringUtils.isEmpty(resDTO.getAccessToken())){ + throw BizRuntimeException.create("fail.api.kt.token.request"); + } + mapper.updateRlaybsnmKtInfo( + CmmEnsRlaybsnmDTO.builder() + .signguCode(paramDTO.getSignguCode()) + .ffnlgCode(paramDTO.getFfnlgCode()) + .profile(profile) + .ktAccessToken(resDTO.getAccessToken()) + .ktTokenExpiresIn(resDTO.getExpiresIn()) + .ktScope(resDTO.getScope()) + .ktTokenJti(resDTO.getJti()) + .build() + ); + cacheService.removeRlaybsnmInfoCache(paramDTO); + return resDTO; + } + +// /** +// * 사전 문자 수신 등록 요청(BC-AG-SN-001) +// * @param reqDTO +// */ +// @Override +// public KtCommonResponse beforeSend(final KtBefSendRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_BEFORE_SEND, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtCommonResponse.class, +// ktMnsInfo +// ); +// +// /*List errors = new ArrayList<>(); +// errors.add(new ErrorMsg("error1")); +// errors.add(new ErrorMsg("error2")); +// +// return KtCommonResponse.builder() +// .resultCd("00") +// .resultDt(DateUtils.getTodayAndNowTime("yyyyMMddHHmmss")) +// .errors(errors) +// .build();*/ +// } +// +// @Override +// public KtCommonResponse mainSend(final KtMainSendRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_MAIN_SEND, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtCommonResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtCommonResponse blacklist(final KtBlacklistRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_BLACKLIST, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtCommonResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtCommonResponse cfmToken(final KtTokenDTO.KtTokenConfirmRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_CFM_TOKEN, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtCommonResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtCommonResponse readToken(final KtTokenReadRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_READ_TOKEN, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtCommonResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtCommonResponse messageResult(final KtMsgRsltRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_RESULT_MESSAGE, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtCommonResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtSendSttcResponse sendSttc(final KtSendSttcRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_SEND_STTC, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtSendSttcResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtSendSttcDtlResponse sendSttcDtl(final KtSendSttcDtlRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_SEND_STTCDTL, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtSendSttcDtlResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtCommonResponse whitelist(final KtWhitelistRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_WHITELIST, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtCommonResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtCommonResponse refuseRcv(final KtRefuseRcvRequest reqDTO) { +// //final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return KtCommonResponse.builder() +// .resultCd("") +// .resultDt("") +// .build(); +// } +// +// @Override +// public KtCommonResponse approveRcv(final KtApproveRcvRequest reqDTO) { +// //final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return KtCommonResponse.builder() +// .resultCd("") +// .resultDt("") +// .build(); +// } +// +// @Override +// public KtAcmdCerfResponse cerfAcmd(final KtAcmdCerfRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_CERF_ACMD, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtAcmdCerfResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtCommonResponse excaAcmd(KtTokenExcaRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_EXCA_ACMD, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtCommonResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtExcaResponse exca(final KtExcaRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_EXCA, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtExcaResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtAcmdInfoResponse infoAcmd(final KtAcmdInfoRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_INFO_ACMD, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtAcmdInfoResponse.class, +// ktMnsInfo +// ); +// } +// +// @Override +// public KtAcmdInfoCfmResponse cfmAcmd(final KtAcmdInfoCfmRequest reqDTO) { +// final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode()); +// //reqDTO.setServiceCd(ktMnsInfo.get); +// //reqDTO.setServiceKey(ktMnsInfo.get); +// CmmEnsUtils.validate(reqDTO); +// +// return webClient.exchangeKt( +// HOST + API_CFM_ACMD, +// HttpMethod.POST, +// JsonUtils.toJson(reqDTO), +// KtAcmdInfoCfmResponse.class, +// ktMnsInfo +// ); +// } +} diff --git a/mens-api/src/main/java/kr/xit/biz/kt/service/IBizKtMmsService.java b/mens-api/src/main/java/kr/xit/biz/kt/service/IBizKtMmsService.java new file mode 100644 index 0000000..e6b12ec --- /dev/null +++ b/mens-api/src/main/java/kr/xit/biz/kt/service/IBizKtMmsService.java @@ -0,0 +1,45 @@ +package kr.xit.biz.kt.service; + + +import kr.xit.biz.ens.model.kt.KtCommonDTO.KtMnsRequest; +import kr.xit.biz.ens.model.kt.KtTokenDTO.KtTokenResponse; + + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.biz.kt.service
+ * fileName    : IBizKtMmsService
+ * author      : limju
+ * date        : 2023-09-22
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2023-09-22    limju       최초 생성
+ *
+ * 
+ */ +public interface IBizKtMmsService { + + KtTokenResponse requestToken(final KtMnsRequest paramDTO); +// KtCommonResponse beforeSend(final KtBefSendRequest reqDTO); +// KtCommonResponse mainSend(final KtMainSendRequest reqDTO); +// KtCommonResponse blacklist(final KtBlacklistRequest reqDTO); +// KtCommonResponse cfmToken(final KtTokenConfirmRequest reqDTO); +// KtCommonResponse readToken(final KtTokenReadRequest reqDTO); +// KtCommonResponse messageResult(final KtMsgRsltRequest reqDTO); +// KtSendSttcResponse sendSttc(final KtSendSttcRequest reqDTO); +// KtSendSttcDtlResponse sendSttcDtl(final KtSendSttcDtlRequest reqDTO); +// KtCommonResponse whitelist(final KtWhitelistRequest reqDTO); +// +// KtCommonResponse refuseRcv(final KtRefuseRcvRequest reqDTO); +// KtCommonResponse approveRcv(final KtApproveRcvRequest reqDTO); +// +// KtAcmdCerfResponse cerfAcmd(final KtAcmdCerfRequest reqDTO); +// +// KtCommonResponse excaAcmd(final KtTokenExcaRequest reqDTO); +// KtExcaResponse exca(final KtExcaRequest reqDTO); +// KtAcmdInfoResponse infoAcmd(final KtAcmdInfoRequest reqDTO); +// KtAcmdInfoCfmResponse cfmAcmd(final KtAcmdInfoCfmRequest reqDTO); +} diff --git a/mens-api/src/main/java/kr/xit/biz/kt/web/BizKtMmsController.java b/mens-api/src/main/java/kr/xit/biz/kt/web/BizKtMmsController.java new file mode 100644 index 0000000..3da6940 --- /dev/null +++ b/mens-api/src/main/java/kr/xit/biz/kt/web/BizKtMmsController.java @@ -0,0 +1,186 @@ +package kr.xit.biz.kt.web; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import kr.xit.biz.ens.model.kt.KtCommonDTO.KtMnsRequest; +import kr.xit.biz.kt.service.IBizKtMmsService; +import kr.xit.core.model.ApiResponseDTO; +import lombok.RequiredArgsConstructor; +import org.springframework.http.MediaType; +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.RestController; + +/** + *
+ * description :
+ *
+ * packageName : kr.xit.biz.kt.web
+ * fileName    : BizKtMmsController
+ * author      : limju
+ * date        : 2023-09-22
+ * ======================================================================
+ * 변경일         변경자        변경 내용
+ * ----------------------------------------------------------------------
+ * 2023-09-22    limju       최초 생성
+ *
+ * 
+ */ +@Tag(name = "BizKtMmsController", description = "KT MMS 업무처리 Controller") +@RequiredArgsConstructor +@RestController +@RequestMapping(value = "/api/biz/kt/v1") +public class BizKtMmsController { + private final IBizKtMmsService service; + + @Operation(summary = "기관용 토큰 발급 요청", description = "기관용 토큰 발급 요청") + @PostMapping(value = "/requestToken", produces = MediaType.APPLICATION_JSON_VALUE) + public ApiResponseDTO requestToken(@RequestBody final KtMnsRequest paramDTO) { + return ApiResponseDTO.success(service.requestToken(paramDTO)); + } +// +// /* +// @io.swagger.v3.oas.annotations.parameters.RequestBody(required = true, content = { +// @Content( +// mediaType = "application/json", +// examples = { +// @ExampleObject( +// value = """ +// { +// "signguCode": "", +// "ffnlgCode": "11", +// "service_cd": "NPS", +// "service_key": "A3AD41349D759DD3", +// "msg_cd": "10006", +// "msg_type": "2", +// "make_dt": "20211229102000", +// "sndn_ex_time": "20211229180000", +// "sndn_tot_cnt": 1, +// "reqs": [ +// { +// "src_key": "S20211229102000001", +// "src_seq": "1", +// "ci": "gdlIa53FZGQz5aKa3wLk33nW57N3mDpcwHytWlWMhzxHKulk7EZs143442394326642342364238648423864237", +// "mdn": "01011112222", "rcve_rf_str":" ○ 수신거부 및 수신 휴대폰 지정하기 :" +// } +// ], +// "opt_type": "2", +// "mktn_rcve_csyn": "N", +// "m_type": "2" +// } +// """) +// }) +// })*/ +// @Operation(summary = "사전 문자 수신 등록 요청", description = "사전 문자 수신 등록 요청(BC-AG-SN-001)") +// @PostMapping(value = "/beforeSend", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO beforeSend(@RequestBody final KtBefSendRequest reqDTO) { +// KtCommonResponse dto = service.beforeSend(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "본문자 수신 등록 요청", description = "본문자 수신 등록 요청(BC-AG-SN-002)") +// @PostMapping(value = "/mainSend", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO mainSend(@RequestBody final KtMainSendRequest reqDTO) { +// KtCommonResponse dto = service.mainSend(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "수신 거부 등록 요청", description = "수신 거부 등록 요청(BC-AG-SN-007)") +// @PostMapping(value = "/blacklist", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO blacklist(@RequestBody final KtBlacklistRequest reqDTO) { +// KtCommonResponse dto = service.blacklist(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "토큰인증확인 조회", description = "토큰인증확인조회요청(BC-AG-SN-008)") +// @PostMapping(value = "/cfmToken", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO cfmToken(@RequestBody final KtTokenConfirmRequest reqDTO) { +// KtCommonResponse dto = service.cfmToken(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "토큰열람확인결과 전송", description = "토큰열람확인결과 전송(BC-AG-SN-009)") +// @PostMapping(value = "/readToken", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO readToken(@RequestBody final KtTokenReadRequest reqDTO) { +// KtCommonResponse dto = service.readToken(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "사전/본 문자 발송/수신 결과 전송 요청", description = "사전/본 문자 발송/수신 결과 전송 요청(BC-AG-SN-010)") +// @PostMapping(value = "/messageResult", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO messageResult(@RequestBody final KtMsgRsltRequest reqDTO) { +// KtCommonResponse dto = service.messageResult(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "백오피스 발송 통계 연계 조회 요청", description = "백오피스 발송 통계 연계 조회 요청(BC-AG-SN-011)") +// @PostMapping(value = "/sendSttc", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO sendSttc(@RequestBody final KtSendSttcRequest reqDTO) { +// KtMmsDTO.KtSendSttcResponse dto = service.sendSttc(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "백오피스 발송 결과 연계 조회 요청", description = "백오피스 발송 결과 연계 조회 요청(BC-AG-SN-012)") +// @PostMapping(value = "/sendSttcDtl", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO sendSttcDtl(@RequestBody final KtSendSttcDtlRequest reqDTO) { +// KtMmsDTO.KtSendSttcDtlResponse dto = service.sendSttcDtl(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "whitelist 등록 요청", description = "whitelist 등록 요청(BC-AG-SN-013)") +// @PostMapping(value = "/whitelist", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO whitelist(@RequestBody final KtWhitelistRequest reqDTO) { +// KtCommonResponse dto = service.whitelist(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "수신거부상태 전송", description = "수신거부상태전송(BC-AG-SN-014)") +// @PostMapping(value = "/refuseRcv", produces = MediaType.APPLICATION_JSON_VALUE) +// public KtCommonResponse refuseRcv(@RequestBody final KtRefuseRcvRequest reqDTO) { +// KtCommonResponse dto = service.refuseRcv(reqDTO); +// return dto; +// } +// +// @Operation(summary = "수신동의상태 전송", description = "수신동의상태전송(BC-AG-SN-015)") +// @PostMapping(value = "/approveRcv", produces = MediaType.APPLICATION_JSON_VALUE) +// public KtCommonResponse approveRcv(@RequestBody final KtApproveRcvRequest reqDTO) { +// KtCommonResponse dto = service.approveRcv(reqDTO); +// return dto; +// } +// +// @Operation(summary = "유통증명서발급처리 요청", description = "유통증명서발급처리 요청(BC-AG-SM-001)") +// @PostMapping(value = "/cerfAcmd", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO cerfAcmd(@RequestBody final KtAcmdCerfRequest reqDTO) { +// KtAcmdCerfResponse dto = service.cerfAcmd(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "가상정산화면 연계토큰 인증 요청", description = "가상정산화면 연계토큰 인증 요청(BC-AG-SM-002)") +// @PostMapping(value = "/excaAcmd", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO excaAcmd(@RequestBody final KtTokenExcaRequest reqDTO) { +// KtCommonResponse dto = service.excaAcmd(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "정산연계자료조회", description = "정산연계자료조회(BC-AG-EC-001)") +// @PostMapping(value = "/exca", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO exca(@RequestBody final KtExcaRequest reqDTO) { +// KtExcaResponse dto = service.exca(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "전자문서 유통정보 수치 조회", description = "전자문서 유통정보 수치 조회(BC-AG-HS-001)") +// @PostMapping(value = "/infoAcmd", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO infoAcmd(@RequestBody final KtAcmdInfoRequest reqDTO) { +// KtAcmdInfoResponse dto = service.infoAcmd(reqDTO); +// return ApiResponseDTO.success(dto); +// } +// +// @Operation(summary = "전자문서 유통정보 수치확인서 발급 처리", description = "전자문서 유통정보 수치확인서 발급 처리(BC-AG-HS-002)") +// @PostMapping(value = "/cfmAcmd", produces = MediaType.APPLICATION_JSON_VALUE) +// public ApiResponseDTO cfmAcmd(@RequestBody final KtAcmdInfoCfmRequest reqDTO) { +// KtAcmdInfoCfmResponse dto = service.cfmAcmd(reqDTO); +// return ApiResponseDTO.success(dto); +// } +} diff --git a/mens-api/src/main/java/kr/xit/core/spring/util/ApiSpringUtils.java b/mens-api/src/main/java/kr/xit/core/spring/util/ApiSpringUtils.java index e4a1767..e7c9aa5 100644 --- a/mens-api/src/main/java/kr/xit/core/spring/util/ApiSpringUtils.java +++ b/mens-api/src/main/java/kr/xit/core/spring/util/ApiSpringUtils.java @@ -1,15 +1,14 @@ package kr.xit.core.spring.util; -import egovframework.com.cmm.EgovMessageSource; import kr.xit.biz.cmm.service.CmmEnsCacheService; import kr.xit.biz.cmm.service.ICmmEnsCacheService; import kr.xit.core.spring.config.support.ApplicationContextProvider; +import kr.xit.ens.kt.service.IKtMmsService; import kr.xit.ens.nice.service.INiceCiService; import kr.xit.ens.nice.service.NiceCiDummyTestService; import lombok.AccessLevel; import lombok.NoArgsConstructor; import org.springframework.context.ApplicationContext; -import org.springframework.core.env.Environment; /** *
@@ -55,6 +54,10 @@ public class ApiSpringUtils {
 		return (INiceCiService)getBean(INiceCiService.class);
 	}
 
+	public static IKtMmsService getKtMmsService(){
+		return (IKtMmsService)getBean(IKtMmsService.class);
+	}
+
 	public static NiceCiDummyTestService getDummyNiceCiService(){
 		return (NiceCiDummyTestService)getBean(NiceCiDummyTestService.class);
 	}
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 8798be5..36814aa 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,17 +2,16 @@ 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;
 import kr.xit.core.spring.util.ApiSpringUtils;
 import kr.xit.core.spring.util.CoreSpringUtils;
+import kr.xit.core.support.utils.DateUtils;
+import kr.xit.ens.kt.service.IKtMmsService;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.commons.lang3.ObjectUtils;
-import org.springframework.core.env.Environment;
-
-import java.util.Objects;
 
 /**
  * 
@@ -34,7 +33,8 @@ import java.util.Objects;
 public class CmmKtMmsUtils {
     private static final EgovMessageSource messageSource = CoreSpringUtils.getMessageSource();
     private static final ICmmEnsCacheService cacheService = ApiSpringUtils.getCmmEnsCacheService();
-    private static final Environment env = CoreSpringUtils.getEnvironment();
+    private static final IKtMmsService ktMmsService = ApiSpringUtils.getKtMmsService();
+
     private static final String profile = System.getProperty("spring.profiles.active");
 
     /**
@@ -42,16 +42,22 @@ public class CmmKtMmsUtils {
      * @return
      */
     public static CmmEnsRlaybsnmDTO getRlaybsnmInfo(final String signguCode, final String ffnlgCode) {
-        final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(
-                CmmEnsRequestDTO.builder()
-                    .signguCode(signguCode)
-                    .ffnlgCode(ffnlgCode)
-                    .profile(profile)
-                    .build());
-        if(ObjectUtils.isEmpty(dto))   throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info"));
+        KtMnsRequest ktReqDTO = KtMnsRequest.builder()
+            .signguCode(signguCode)
+            .ffnlgCode(ffnlgCode)
+            .profile(profile)
+            .build();
+
+        final CmmEnsRlaybsnmDTO dto = cacheService.getRlaybsnmInfoCache(ktReqDTO);
         cacheService.logCache();
 
-        return dto;
+        if(ObjectUtils.isEmpty(dto))   throw BizRuntimeException.create(messageSource.getMessage("fail.api.rlaybsnm.info"));
+
+        // 토큰 유효기간 체크
+        if(DateUtils.getTodayAndNowTime("yyyy-MM-dd HH:mm:ss").compareTo(dto.getKtTokenExpiresIn()) < 0)     return dto;
+
+        ktMmsService.requestToken(ktReqDTO);
+        return cacheService.getRlaybsnmInfoCache(ktReqDTO);
     }
 
 
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 f4711f9..cd26cfc 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
@@ -1,6 +1,5 @@
 package kr.xit.ens.kt.service;
 
-import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.Map;
 import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO;
@@ -149,11 +148,6 @@ public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsServi
     @Value("${contract.kt.api.approve-rcv}")
     private String API_APPROVE_RCV;
 
-
-
-
-    private static final String AUTH_TYPE_BEARER = "Bearer";
-
     private final ApiWebClientUtil webClient;
 
     /**
@@ -163,36 +157,24 @@ public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsServi
     public KtTokenResponse requestToken(final KtMnsRequest paramDTO) {
         final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(paramDTO.getSignguCode(), paramDTO.getFfnlgCode());
         final KtTokenRequest reqDTO = KtTokenRequest.builder()
-            //.clientId(ktMnsInfo.getKtClientId())
-            .clientId(URLEncoder.encode(ktMnsInfo.getKtSvcClientId()))
-            .clientSecret(URLEncoder.encode(ktMnsInfo.getKtSvcClientSecret()))
-            .scope(URLEncoder.encode(ktMnsInfo.getKtScope()))
+            .clientId(ktMnsInfo.getKtSvcClientId())
+            .clientSecret(ktMnsInfo.getKtSvcClientSecret())
+            .scope(ktMnsInfo.getKtScope())
             .build();
         CmmEnsUtils.validate(reqDTO);
 
         final Map headerMap = new HashMap<>();
-        headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
-//        headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
+        headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
         headerMap.put("client-id", ktMnsInfo.getKtClientId());
         headerMap.put("client-tp", ktMnsInfo.getKtClientTp());
-//        headerMap.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, "access-token"));
 
-        return webClient.exchange(
+        return webClient.exchangeFormData(
             HOST + API_GENERATE_TOKEN,
             HttpMethod.POST,
-            JsonUtils.toJson(reqDTO),
+            reqDTO,
             KtTokenResponse.class,
             headerMap
         );
-
-//        return KtTokenResponse.builder()
-//            .accessToken("eyJhbGciOiJSUzI1NiIsI…")
-//            .expiresIn("7776000")
-//            .scope("ag.api")
-//            .jti("67410d77-0064-4694-9da9..")
-//            .error("sjj")
-//            .errorDescription("jjjjjjj")
-//            .build();
     }
 
     /**
@@ -204,6 +186,10 @@ public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsServi
         final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());
         //reqDTO.setServiceCd(ktMnsInfo.get);
         //reqDTO.setServiceKey(ktMnsInfo.get);
+        reqDTO.setServiceCd(ktMnsInfo.getKtServiceCode());
+        reqDTO.setSignguCode(null);
+        reqDTO.setFfnlgCode(null);
+        reqDTO.setProfile(null);
         CmmEnsUtils.validate(reqDTO);
 
         return webClient.exchangeKt(
@@ -230,6 +216,10 @@ public class KtMmsService extends EgovAbstractServiceImpl implements IKtMmsServi
         final CmmEnsRlaybsnmDTO ktMnsInfo = CmmKtMmsUtils.getRlaybsnmInfo(reqDTO.getSignguCode(), reqDTO.getFfnlgCode());
         //reqDTO.setServiceCd(ktMnsInfo.get);
         //reqDTO.setServiceKey(ktMnsInfo.get);
+        reqDTO.setServiceCd(ktMnsInfo.getKtServiceCode());
+        reqDTO.setSignguCode(null);
+        reqDTO.setFfnlgCode(null);
+        reqDTO.setProfile(null);
         CmmEnsUtils.validate(reqDTO);
 
         return webClient.exchangeKt(
diff --git a/mens-api/src/main/java/kr/xit/ens/kt/web/KtMmsController.java b/mens-api/src/main/java/kr/xit/ens/kt/web/KtMmsController.java
index 7d9c754..3145b13 100644
--- a/mens-api/src/main/java/kr/xit/ens/kt/web/KtMmsController.java
+++ b/mens-api/src/main/java/kr/xit/ens/kt/web/KtMmsController.java
@@ -5,33 +5,35 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import kr.xit.biz.cmm.service.ICmmEnsCacheService;
 import kr.xit.biz.ens.model.kt.KtAcmdDTO.KtAcmdCerfRequest;
 import kr.xit.biz.ens.model.kt.KtAcmdDTO.KtAcmdCerfResponse;
-import kr.xit.biz.ens.model.kt.KtAcmdDTO.KtAcmdInfoRequest;
-import kr.xit.biz.ens.model.kt.KtAcmdDTO.KtAcmdInfoResponse;
 import kr.xit.biz.ens.model.kt.KtAcmdDTO.KtAcmdInfoCfmRequest;
 import kr.xit.biz.ens.model.kt.KtAcmdDTO.KtAcmdInfoCfmResponse;
+import kr.xit.biz.ens.model.kt.KtAcmdDTO.KtAcmdInfoRequest;
+import kr.xit.biz.ens.model.kt.KtAcmdDTO.KtAcmdInfoResponse;
 import kr.xit.biz.ens.model.kt.KtCommonDTO.KtCommonResponse;
 import kr.xit.biz.ens.model.kt.KtCommonDTO.KtMnsRequest;
-import kr.xit.biz.ens.model.kt.KtExcaDTO;
+import kr.xit.biz.ens.model.kt.KtExcaDTO.KtExcaRequest;
+import kr.xit.biz.ens.model.kt.KtExcaDTO.KtExcaResponse;
 import kr.xit.biz.ens.model.kt.KtInputDTO.KtApproveRcvRequest;
 import kr.xit.biz.ens.model.kt.KtInputDTO.KtRefuseRcvRequest;
 import kr.xit.biz.ens.model.kt.KtMmsDTO;
-import kr.xit.biz.ens.model.kt.KtMmsDTO.KtSendSttcRequest;
-import kr.xit.biz.ens.model.kt.KtMmsDTO.KtSendSttcDtlRequest;
 import kr.xit.biz.ens.model.kt.KtMmsDTO.KtBlacklistRequest;
+import kr.xit.biz.ens.model.kt.KtMmsDTO.KtSendSttcDtlRequest;
+import kr.xit.biz.ens.model.kt.KtMmsDTO.KtSendSttcRequest;
 import kr.xit.biz.ens.model.kt.KtMmsDTO.KtWhitelistRequest;
-import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMsgRsltRequest;
-import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendRequest;
 import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtBefSendRequest;
-import kr.xit.biz.ens.model.kt.KtExcaDTO.KtExcaRequest;
-import kr.xit.biz.ens.model.kt.KtExcaDTO.KtExcaResponse;
+import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMainSendRequest;
+import kr.xit.biz.ens.model.kt.KtMmsSendDTO.KtMsgRsltRequest;
+import kr.xit.biz.ens.model.kt.KtTokenDTO.KtTokenConfirmRequest;
 import kr.xit.biz.ens.model.kt.KtTokenDTO.KtTokenExcaRequest;
 import kr.xit.biz.ens.model.kt.KtTokenDTO.KtTokenReadRequest;
-import kr.xit.biz.ens.model.kt.KtTokenDTO.KtTokenConfirmRequest;
 import kr.xit.core.model.ApiResponseDTO;
 import kr.xit.ens.kt.service.IKtMmsService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
+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.RestController;
 
 /**
  * 
diff --git a/mens-api/src/main/java/kr/xit/ens/pplus/service/PplusService.java b/mens-api/src/main/java/kr/xit/ens/pplus/service/PplusService.java
index 79e4b0d..fcfeab8 100644
--- a/mens-api/src/main/java/kr/xit/ens/pplus/service/PplusService.java
+++ b/mens-api/src/main/java/kr/xit/ens/pplus/service/PplusService.java
@@ -103,7 +103,7 @@ public class PplusService extends EgovAbstractServiceImpl implements IPplusServi
 //        headerMap.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, "access-token"));
 
 
-        return webClient.exchangeFile(
+        return webClient.exchangeFileData(
             HOST + ACCEPT,
             HttpMethod.POST,
             pstFiles,
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 153c3c2..f7144d7 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
@@ -52,7 +52,7 @@
            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(from_unixtime(kt_token_expires_in, '%Y%m%d%H%i%s'), INTERVAL -1 HOUR) AS ktTokenExpiresIn,     /* KT 토큰 유효기간 */
+           DATE_ADD(NOW(), INTERVAL kt_token_expires_in - 86400 SECOND) AS ktTokenExpiresIn,     /* KT 토큰 유효기간 : (7775999)(90일) */
            kt_token_jti,            /* KT 토큰 식별자 */
            epost_service_key,       /* epost service key */
            pplus_api_key,           /* postplus api key */
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
new file mode 100644
index 0000000..0880b65
--- /dev/null
+++ b/mens-api/src/main/resources/egovframework/mapper/biz/ens-kt-mysql-mapper.xml
@@ -0,0 +1,21 @@
+
+
+
+
+  
+    /** 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},
+           updt_dt = now(),
+           updusr = 'api-biz'
+     WHERE signgu_code = #{signguCode}
+       AND ffnlg_code = #{ffnlgCode}
+  
+
+
+
+
diff --git a/mens-api/src/main/resources/egovframework/messages/message-api.properties b/mens-api/src/main/resources/egovframework/messages/message-api.properties
index 92a31b6..486e2c9 100644
--- a/mens-api/src/main/resources/egovframework/messages/message-api.properties
+++ b/mens-api/src/main/resources/egovframework/messages/message-api.properties
@@ -6,3 +6,4 @@ fail.api.nice.revoke.token=\uD1A0\uD070(NICE) \uD3D0\uAE30\uC5D0 \uC2E4\uD328\uD
 fail.api.nice.invalid.tranId=NICE \uC778\uC99D \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD558\uC600\uC2B5\uB2C8\uB2E4(TRAN_ID \uBD88\uC77C\uCE58)
 
 fail.api.rlaybsnm.info=\uBB38\uC11C\uC911\uACC4\uC790 \uC778\uC99D \uC815\uBCF4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.
+fail.api.kt.token.request=KT \uD1A0\uD070 \uC694\uCCAD\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.
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 ff536e6..72b7738 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
@@ -38,6 +38,10 @@ public class CmmEnsRlaybsnmDTO extends AuditFields implements Serializable {
      * 과태료 코드
      */
     private String ffnlgCode;
+    /**
+     * profile
+     */
+    private String profile;
     /**
      * 시군구 명
      */
diff --git a/mens-core/src/main/java/kr/xit/biz/ens/model/kt/KtMmsSendDTO.java b/mens-core/src/main/java/kr/xit/biz/ens/model/kt/KtMmsSendDTO.java
index fded6f7..bafcf5c 100644
--- a/mens-core/src/main/java/kr/xit/biz/ens/model/kt/KtMmsSendDTO.java
+++ b/mens-core/src/main/java/kr/xit/biz/ens/model/kt/KtMmsSendDTO.java
@@ -11,6 +11,7 @@ import javax.validation.Valid;
 import javax.validation.constraints.Digits;
 import javax.validation.constraints.Size;
 import kr.xit.biz.ens.model.kt.KtCommonDTO.KtCommonResponse;
+import kr.xit.core.support.utils.DateUtils;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.Getter;
@@ -87,7 +88,7 @@ public class KtMmsSendDTO {
          * 문서코드에 따라 발신번호 Mapping
          * 
*/ - @Schema(requiredMode = RequiredMode.REQUIRED, title = "문서코드", example = "10006") + @Schema(requiredMode = RequiredMode.REQUIRED, title = "문서코드", example = "DP112") @Size(min = 5, max = 5, message = "문서 코드는 필수 입니다(max:5)") private String msgCd; @@ -401,7 +402,7 @@ public class KtMmsSendDTO { * 문서코드에 따라 발신번호 Mapping *
*/ - @Schema(requiredMode = RequiredMode.REQUIRED, title = "문서코드", example = "10006") + @Schema(requiredMode = RequiredMode.REQUIRED, title = "문서코드", example = "DP112") @Size(min = 5, max = 5, message = "문서 코드는 필수 입니다(max:5)") private String msgCd; @@ -934,7 +935,7 @@ public class KtMmsSendDTO { */ @Schema(requiredMode = RequiredMode.REQUIRED, title = "발송타임스탬프", example = " ") @Size(min = 14, max = 14, message = "발송타임스탬프는 필수 입니다(YYYYMMDDHHMISS)") - private String mmsSndgTmst; + private final String mmsSndgTmst = DateUtils.getTodayAndNowTime("yyyyMMddHHmmss"); /** *
diff --git a/mens-core/src/main/java/kr/xit/core/spring/config/support/WebClientConfig.java b/mens-core/src/main/java/kr/xit/core/spring/config/support/WebClientConfig.java
index fb834d5..adff64a 100644
--- a/mens-core/src/main/java/kr/xit/core/spring/config/support/WebClientConfig.java
+++ b/mens-core/src/main/java/kr/xit/core/spring/config/support/WebClientConfig.java
@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.http.client.reactive.ReactorClientHttpConnector;
@@ -71,6 +72,7 @@ public class WebClientConfig {
         factory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.VALUES_ONLY);
 
         return WebClient.builder()
+                .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
                 .uriBuilderFactory(factory)
                 .clientConnector(new ReactorClientHttpConnector(defaultHttpClient()))
                 .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(2 * 1024 * 1024))
@@ -148,7 +150,7 @@ public class WebClientConfig {
 
     /**
      * reponse logging && error Handling
-     * @return
+     * @return ExchangeFilterFunction
      */
     private ExchangeFilterFunction responseFilter() {
         return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> {
diff --git a/mens-core/src/main/java/kr/xit/core/spring/util/ApiWebClientUtil.java b/mens-core/src/main/java/kr/xit/core/spring/util/ApiWebClientUtil.java
index 5a84564..5a4c448 100644
--- a/mens-core/src/main/java/kr/xit/core/spring/util/ApiWebClientUtil.java
+++ b/mens-core/src/main/java/kr/xit/core/spring/util/ApiWebClientUtil.java
@@ -7,31 +7,28 @@ import java.util.Map;
 import java.util.Objects;
 import kr.xit.biz.ens.model.cmm.CmmEnsRlaybsnmDTO;
 import kr.xit.core.consts.Constants;
-import kr.xit.core.exception.BizRuntimeException;
 import kr.xit.core.model.ApiResponseDTO;
 import kr.xit.core.spring.config.support.WebClientConfig;
 import kr.xit.core.spring.util.error.ClientError;
 import kr.xit.core.spring.util.error.ErrorParse;
 import kr.xit.core.spring.util.error.ServerError;
+import kr.xit.core.support.utils.JsonUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.http.client.MultipartBodyBuilder;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.reactive.function.BodyInserters;
-import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
 import org.springframework.web.util.UriComponentsBuilder;
-import reactor.core.publisher.Mono;
 
 /**
  * 
  * description : react Restfull Util
- *
+ *               error(.onStatus)는 ExchangeFilterFunction {@link WebClientConfig#responseFilter responseFilter} 에서 처리
  * packageName : kr.xit.core.spring.util
  * fileName    : ApiWebClientUtil
  * author      : julim
@@ -42,6 +39,7 @@ import reactor.core.publisher.Mono;
  * 2023-09-06    julim       최초 생성
  *
  * 
+ * @see WebClientConfig * @see kr.xit.core.spring.config.AsyncExecutorConfig * @see ClientError * @see ServerError @@ -52,44 +50,63 @@ import reactor.core.publisher.Mono; @Component @RequiredArgsConstructor public class ApiWebClientUtil { - private static final String AUTH_TYPE_BEARER = "Bearer"; + private static final String AUTH_TYPE_BEARER = "bearer"; private final WebClientConfig webClientConfig; - private enum EnsDIV{ - KKO, - KT, - PPLUS - }; - + /** + * WebClient GET 호출 처리 + * 에러(.onStatus status.is4xxClientError() || status.is5xxServerError()) + * -> {@link WebClientConfig#responseFilter responseFilter} 에서 처리 + * @param url + * @param responseDtoClass + * @param headerMap + * @return responseDtoClass + */ public T get(final String url, final Class responseDtoClass, Map headerMap) { - return webClientConfig.webClient().method(HttpMethod.GET) + return webClientConfig.webClient() + .method(HttpMethod.GET) .uri(url) .headers(httpHeaders -> getHeaders(httpHeaders, headerMap)) .retrieve() - .onStatus( - status -> status.is4xxClientError() || status.is5xxServerError(), - res -> res.bodyToMono(String.class).map(BizRuntimeException::create)) .bodyToMono(responseDtoClass) .block(); } + /** + * WebClient POST 호출 처리 + * 에러(.onStatus status.is4xxClientError() || status.is5xxServerError()) + * -> {@link WebClientConfig#responseFilter responseFilter} 에서 처리 + * @param url + * @param requestDto + * @param responseDtoClass + * @param headerMap + * @return responseDtoClass + */ public T post(final String url, final V requestDto, final Class responseDtoClass, Map headerMap) { - return webClientConfig.webClient().method(HttpMethod.POST) + return webClientConfig.webClient() + .method(HttpMethod.POST) .uri(url) .headers(httpHeaders -> getHeaders(httpHeaders, headerMap)) .bodyValue(Objects.requireNonNullElse(requestDto, "")) .retrieve() - .onStatus( - status -> status.is4xxClientError() || status.is5xxServerError(), - res -> res.bodyToMono(String.class).map(BizRuntimeException::create)) .bodyToMono(responseDtoClass) .block(); } + /** + * kakao WebClient 호출 처리 + * 에러(.onStatus status.is4xxClientError() || status.is5xxServerError()) + * -> {@link WebClientConfig#responseFilter responseFilter} 에서 처리 + * @param url + * @param method + * @param body + * @param rtnClzz + * @param ensDTO CmmEnsRlaybsnmDTO + * @return rtnClzz + */ public T exchangeKko(final String url, final HttpMethod method, final Object body, final Class rtnClzz, final CmmEnsRlaybsnmDTO ensDTO) { Map map = new HashMap<>(); - map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); map.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", Constants.JwtToken.GRANT_TYPE.getCode(), ensDTO.getKakaoAccessToken())); map.put(Constants.HeaderName.UUID.getCode(), ensDTO.getKakaoContractUuid()); @@ -99,17 +116,19 @@ public class ApiWebClientUtil { public T exchangeKt(final String url, final HttpMethod method, final Object body, final Class rtnClzz, final CmmEnsRlaybsnmDTO ensDTO) { final Map headerMap = new HashMap<>(); - headerMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); headerMap.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, ensDTO.getKtAccessToken())); headerMap.put("client-id", ensDTO.getKtClientId()); - headerMap.put("client-tp", "10"); + headerMap.put("client-tp", ensDTO.getKtClientTp()); return exchange(url, method, body, rtnClzz, headerMap); } /** *
-     * Async call - Response Entity(상태정보등) 가 필요한 경우
+     * WebClient 호출 처리
+     * GET 요청시 url에 파라메터를 포함해야 함(?key=value&key2=value2)
+     * 에러(.onStatus status.is4xxClientError() || status.is5xxServerError())
+     * -> {@link WebClientConfig#responseFilter responseFilter} 에서 처리
      * @param url call url
      * @param method POST|GET
      * @param body JSON String type
@@ -125,26 +144,51 @@ public class ApiWebClientUtil {
             .uri(url)
             .headers(httpHeaders -> getHeaders(httpHeaders, headerMap))
             .bodyValue(Objects.requireNonNullElse(body, ""))
-            .exchangeToMono(res -> res.bodyToMono(rtnClzz)
-                .map(dto -> {
-                    if (res.statusCode().is2xxSuccessful()) {
-                        log.info("API 요청에 성공했습니다.");
-                        return dto;
-                    }
+            .exchangeToMono(res -> res.bodyToMono(rtnClzz))
+            .block();
+    }
 
-                    if (res.statusCode().is4xxClientError()) {
-                        log.error("API 요청 중 4xx 에러가 발생했습니다. 요청 데이터를 확인해주세요.");
-                        throw BizRuntimeException.create(String.format("4xx 외부 요청 오류. statusCode: %s, response: %s, header: %s", res.rawStatusCode(), res.bodyToMono(String.class), res.headers().asHttpHeaders()));
-                    }
+    /**
+     * 
+     * WebClient form data 호출 처리
+     * -> application/x-www-form-urlencoded 전송시
+     * GET 요청시 url에 파라메터를 포함해야 함(?key=value&key2=value2)
+     * 에러(.onStatus status.is4xxClientError() || status.is5xxServerError())
+     * -> {@link WebClientConfig#responseFilter responseFilter} 에서 처리
+     * @param url call url
+     * @param method POST|GET
+     * @param body JSON String type
+     * @param rtnClzz rtnClzz return type class
+     *        (ex: new KkopayDocDTO.DocStatusResponse().getClass())
+     * @return T rtnClzz return DTO
+     * 
+ */ + public T exchangeFormData(final String url, final HttpMethod method, final Object body, final Class rtnClzz, final Map headerMap) { - log.error("API 요청 중 Tree 서버에서 5xx 에러가 발생했습니다."); - throw BizRuntimeException.create(String.format("5xx 외부 시스템 오류. %s", res.bodyToMono(String.class))); - }) - ) + return webClientConfig.webClient() + .method(method) + .uri(url) + .headers(httpHeaders -> getHeaders(httpHeaders, headerMap)) + .body(BodyInserters.fromFormData(JsonUtils.toMultiValue(body))) + .exchangeToMono(res -> res.bodyToMono(rtnClzz)) .block(); } - public T exchangeFile(final String url, final HttpMethod method, final List files, final String uploadFileName, final Class rtnClzz, final Map headerMap) { + /** + * webclient file data 호출 처리 + * -> multipart/form-data 전송시 + * GET 요청시 url에 파라메터를 포함해야 함(?key=value&key2=value2) + * 에러(.onStatus status.is4xxClientError() || status.is5xxServerError()) + * -> {@link WebClientConfig#responseFilter responseFilter} 에서 처리 + * @param url + * @param method + * @param files + * @param uploadFileName + * @param rtnClzz + * @param headerMap + * @return rtnClzz + */ + public T exchangeFileData(final String url, final HttpMethod method, final List files, final String uploadFileName, final Class rtnClzz, final Map headerMap) { MultipartBodyBuilder builder = new MultipartBodyBuilder(); for(MultipartFile mf : files) { builder.part(mf.getOriginalFilename(), mf.getResource()); @@ -156,78 +200,14 @@ public class ApiWebClientUtil { .contentType(MediaType.MULTIPART_FORM_DATA) .headers(httpHeaders -> getHeaders(httpHeaders, headerMap)) .body(BodyInserters.fromMultipartData(builder.build())) - .exchangeToMono(res -> res.bodyToMono(rtnClzz) - .map(dto -> { - if (res.statusCode().is2xxSuccessful()) { - log.info("API 요청에 성공했습니다."); - return dto; - } - - if (res.statusCode().is4xxClientError()) { - log.error("API 요청 중 4xx 에러가 발생했습니다. 요청 데이터를 확인해주세요."); - throw BizRuntimeException.create(String.format("4xx 외부 요청 오류. statusCode: %s, response: %s, header: %s", res.rawStatusCode(), res.bodyToMono(String.class), res.headers().asHttpHeaders())); - } - - log.error("API 요청 중 Tree 서버에서 5xx 에러가 발생했습니다."); - throw BizRuntimeException.create(String.format("5xx 외부 시스템 오류. %s", res.bodyToMono(String.class))); - }) - ) + .exchangeToMono(res -> res.bodyToMono(rtnClzz)) .block(); } -// public T exchange(final String url, final HttpMethod method, final Object body, final Class rtnClzz, final Map headerMap) { -// -// return webClientConfig.webClient() -// .method(method) -// .uri(url) -// .headers(httpHeaders -> getHeaders(httpHeaders, headerMap)) -// .bodyValue(Objects.requireNonNullElse(body, "")) -// .exchangeToMono(res -> res.bodyToMono(rtnClzz) -// .map(dto -> { -// if (res.statusCode().is2xxSuccessful()) { -// log.info("API 요청에 성공했습니다."); -// return dto; -// } -// -// if (res.statusCode().is4xxClientError()) { -// log.error("API 요청 중 4xx 에러가 발생했습니다. 요청 데이터를 확인해주세요."); -// throw BizRuntimeException.create(String.format("4xx 외부 요청 오류. statusCode: %s, response: %s, header: %s", res.rawStatusCode(), res.bodyToMono(String.class), res.headers().asHttpHeaders())); -// } -// -// log.error("API 요청 중 Tree 서버에서 5xx 에러가 발생했습니다."); -// throw BizRuntimeException.create(String.format("5xx 외부 시스템 오류. %s", res.bodyToMono(String.class))); -// }) -// ) -// .block(); -// } - public ApiResponseDTO sendError(final Throwable e) { return ErrorParse.extractError(e.getCause()); } - -// private Map getHeaderMap(final EnsDIV ensDIV, final CmmEnsRlaybsnmDTO ensDTO){ -// Map map = new HashMap<>(); -// -// switch(ensDIV){ -// case KKO: -// map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); -// map.put(HttpHeaders.AUTHORIZATION, -// String.format("%s %s", Constants.JwtToken.GRANT_TYPE.getCode(), ensDTO.getKakaoAccessToken())); -// map.put(Constants.HeaderName.UUID.getCode(), ensDTO.getKakaoContractUuid()); -// break; -// case KT: -// map.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); -// map.put(HttpHeaders.AUTHORIZATION, String.format("%s %s", AUTH_TYPE_BEARER, ensDTO.getKtAccessToken())); -// map.put("client-id", ensDTO.getKtClientId()); -// map.put("client-tp", "10"); -// break; -// default: -// throw BizRuntimeException.create("서비스 불가한 문서중계자 입니다"); -// } -// return map; -// } - private URI createUrl(final String endPoint, final String... value) { return UriComponentsBuilder.fromUriString(endPoint) .build(value); @@ -240,21 +220,4 @@ public class ApiWebClientUtil { } return headers; } - - private ExchangeFilterFunction errorHandler() { - return ExchangeFilterFunction.ofResponseProcessor(clientResponse -> { - HttpStatus status = clientResponse.statusCode(); - - if (clientResponse.statusCode().is4xxClientError()) { - return clientResponse.bodyToMono(String.class) - .flatMap(errorBody -> Mono.error(new ClientError(status, errorBody))); - - } else if (clientResponse.statusCode().is5xxServerError()) { - return clientResponse.bodyToMono(String.class) - .flatMap(errorBody -> Mono.error(new ServerError(status, errorBody))); - - } - return Mono.just(clientResponse); - }); - } } diff --git a/mens-core/src/main/java/kr/xit/core/support/utils/JsonUtils.java b/mens-core/src/main/java/kr/xit/core/support/utils/JsonUtils.java index a9c0352..30c4add 100644 --- a/mens-core/src/main/java/kr/xit/core/support/utils/JsonUtils.java +++ b/mens-core/src/main/java/kr/xit/core/support/utils/JsonUtils.java @@ -13,6 +13,8 @@ import lombok.NoArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.json.simple.JSONArray; import org.json.simple.JSONObject; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; /** @@ -123,6 +125,23 @@ public class JsonUtils { } } + /** + * Object의 key와 value를 추출 + * -> key배열, value배열의 JSONObject return + * @param obj key, value를 추출할 Object + * @param keyName key배열의 JSON key name + * @param valueName value배열의 JSON key name + * @return JSONObject key배열, value배열의 JSONObject + */ + public static MultiValueMap toMultiValue(final Object obj){ + MultiValueMap formData = new LinkedMultiValueMap<>(); + JSONObject jsonObj = toObjByObj(obj, JSONObject.class); + for (Object key : jsonObj.keySet()) { + formData.add((String) key, (String) jsonObj.get(key)); + } + return formData; + } + /** * Object의 key와 value를 추출 * -> key배열, value배열의 JSONObject return