refactor: apply GlowMciComponent architecture as requested by Shinhan Life standard
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package io.shinhanlife.dap.mcc.component;
|
||||
|
||||
import io.shinhanlife.glow.communication.dto.Transfer;
|
||||
import io.shinhanlife.glow.communication.module.mci.component.GlowMciComponent;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 신한라이프 내부 Glow 표준 컴포넌트 어댑터
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class LicoMciComponent {
|
||||
|
||||
private final GlowMciComponent<Object, Object> mci;
|
||||
|
||||
public <O, I> Transfer<O> callTo(String itrfName, String rcvSvcId, I inputDto, Class<O> resBodyClass) {
|
||||
log.info("[LicoMciComponent] MCI 호출 준비 - 인터페이스: {}", itrfName);
|
||||
|
||||
// Header 세팅 로직 생략 (Mock)
|
||||
|
||||
Transfer<Object> request = Transfer.builder()
|
||||
.body(inputDto)
|
||||
.resBodyClass((Class<Object>) resBodyClass)
|
||||
.build();
|
||||
|
||||
return syncMci(request);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <O> Transfer<O> syncMci(Transfer<Object> request) {
|
||||
log.info("[LicoMciComponent] GlowMciComponent.sync() 호출");
|
||||
return (Transfer<O>) mci.sync(request);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,13 @@
|
||||
package io.shinhanlife.dap.mcc.service;
|
||||
|
||||
import io.shinhanlife.dap.common.adapter.sender.ShinhanMciSender;
|
||||
import io.shinhanlife.dap.common.integration.mci.dto.MciRequestWrapper;
|
||||
import io.shinhanlife.dap.common.integration.mci.dto.ShinhanCommonHeaderDto;
|
||||
import io.shinhanlife.dap.mcc.component.LicoMciComponent;
|
||||
import io.shinhanlife.glow.communication.dto.Transfer;
|
||||
import org.springframework.stereotype.Service;
|
||||
import io.shinhanlife.dap.mcc.annotation.McpFunction;
|
||||
import io.shinhanlife.dap.mcc.annotation.McpTool;
|
||||
import lombok.Data;
|
||||
import io.shinhanlife.dap.mcc.dto.Onnba3011ReqDto;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import io.shinhanlife.dap.mcc.dto.Onnba3011ReqDto;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @package io.shinhanlife.dap.mcc.service
|
||||
@@ -32,13 +29,10 @@ import org.springframework.stereotype.Service;
|
||||
@McpTool(routingType = "MCI", categoryKey = "other")
|
||||
public class OnnbaMciToolService {
|
||||
|
||||
// 프레임워크에서 제공하는 공통 MCI 발송 어댑터 주입
|
||||
private final ShinhanMciSender shinhanMciSender;
|
||||
|
||||
@Value("${shinhan.integration.mci.default-url:http://localhost:8081/api/mock/esb/api}")
|
||||
private String mciTargetUrl;
|
||||
|
||||
private static final String INTERFACE_CODE_3011 = "CLCNNB00001";
|
||||
|
||||
// Glow 기반의 LicoMciComponent 주입
|
||||
private final LicoMciComponent mci;
|
||||
|
||||
/**
|
||||
* AI Agent가 호출하게 될 메서드입니다.
|
||||
@@ -50,31 +44,24 @@ public class OnnbaMciToolService {
|
||||
displayName = "보종By가입설계한도계산조회",
|
||||
description = "MCI 연동을 통해 보종By가입설계한도계산조회를 수행합니다.",
|
||||
prompt = "가입설계 한도를 계산하고 조회해줘.",
|
||||
mappingId = "CLCNNB00001"
|
||||
mappingId = INTERFACE_CODE_3011
|
||||
)
|
||||
public Object callOnnba3011(Onnba3011ReqDto req) {
|
||||
log.info("[MCI Tool] 보종By가입설계한도계산조회 요청 수신.");
|
||||
|
||||
try {
|
||||
// 1. MCI 전문 통신을 위한 통합 Wrapper 객체 생성
|
||||
MciRequestWrapper<Onnba3011ReqDto> wrapper = new MciRequestWrapper<>();
|
||||
// GlowMciComponent 표준 방식 (Transfer 객체 이용)
|
||||
Transfer<Object> resTransfer = mci.callTo(
|
||||
INTERFACE_CODE_3011,
|
||||
null, // rcvSvcId
|
||||
req,
|
||||
Object.class
|
||||
);
|
||||
|
||||
// 2. 공통 헤더 세팅
|
||||
ShinhanCommonHeaderDto header = new ShinhanCommonHeaderDto();
|
||||
header.setItrIfId("CLCNNB00001");
|
||||
wrapper.setTgrmCmnnhddValu(header);
|
||||
log.info("[MCI Tool] Glow 기반 MCI 연동 성공.");
|
||||
|
||||
// 3. 비즈니스 데이터(Body) 세팅
|
||||
wrapper.setBody(req);
|
||||
|
||||
// 4. ShinhanMciSender를 통해 통합 JSON 연동 수행 및 응답 수신
|
||||
log.info("[MCI Tool] ShinhanMciSender 연동 시작... (URL: {})", mciTargetUrl);
|
||||
String responseJson = shinhanMciSender.send(mciTargetUrl, wrapper);
|
||||
|
||||
log.info("[MCI Tool] MCI 연동 성공.");
|
||||
|
||||
// 결과 반환
|
||||
return responseJson;
|
||||
// 결과 반환 (실제로는 resTransfer.getBody() 리턴)
|
||||
return resTransfer.getBody() != null ? resTransfer.getBody() : "{\"status\":\"SUCCESS\", \"message\":\"GlowMciComponent 통신 완료\"}";
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[MCI Tool] MCI 연동 중 오류 발생: {}", e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user