refactor: apply GlowMciComponent architecture as requested by Shinhan Life standard
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
package io.shinhanlife.glow.communication.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: 실제 Glow Framework 의존성(JAR)이 추가되면 이 Mock 클래스를 삭제하세요.
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Transfer<T> {
|
||||||
|
private Object header;
|
||||||
|
private T body;
|
||||||
|
private Class<T> resBodyClass;
|
||||||
|
private Object message;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package io.shinhanlife.glow.communication.module.mci.component;
|
||||||
|
|
||||||
|
import io.shinhanlife.glow.communication.dto.Transfer;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: 실제 Glow Framework 의존성(JAR)이 추가되면 이 Mock 클래스를 삭제하세요.
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class GlowMciComponent<S, R> {
|
||||||
|
|
||||||
|
public Transfer<R> sync(Transfer<S> request) {
|
||||||
|
// 실제 Glow HTTP 통신 (GlowHttpHeaderUtil, HttpClient 등) 수행 시뮬레이션
|
||||||
|
return (Transfer<R>) Transfer.builder()
|
||||||
|
.body(new Object())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
package io.shinhanlife.dap.mcc.service;
|
||||||
|
|
||||||
import io.shinhanlife.dap.common.adapter.sender.ShinhanMciSender;
|
import io.shinhanlife.dap.mcc.component.LicoMciComponent;
|
||||||
import io.shinhanlife.dap.common.integration.mci.dto.MciRequestWrapper;
|
import io.shinhanlife.glow.communication.dto.Transfer;
|
||||||
import io.shinhanlife.dap.common.integration.mci.dto.ShinhanCommonHeaderDto;
|
import org.springframework.stereotype.Service;
|
||||||
import io.shinhanlife.dap.mcc.annotation.McpFunction;
|
import io.shinhanlife.dap.mcc.annotation.McpFunction;
|
||||||
import io.shinhanlife.dap.mcc.annotation.McpTool;
|
import io.shinhanlife.dap.mcc.annotation.McpTool;
|
||||||
import lombok.Data;
|
import io.shinhanlife.dap.mcc.dto.Onnba3011ReqDto;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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
|
* @package io.shinhanlife.dap.mcc.service
|
||||||
@@ -32,13 +29,10 @@ import org.springframework.stereotype.Service;
|
|||||||
@McpTool(routingType = "MCI", categoryKey = "other")
|
@McpTool(routingType = "MCI", categoryKey = "other")
|
||||||
public class OnnbaMciToolService {
|
public class OnnbaMciToolService {
|
||||||
|
|
||||||
// 프레임워크에서 제공하는 공통 MCI 발송 어댑터 주입
|
private static final String INTERFACE_CODE_3011 = "CLCNNB00001";
|
||||||
private final ShinhanMciSender shinhanMciSender;
|
|
||||||
|
|
||||||
@Value("${shinhan.integration.mci.default-url:http://localhost:8081/api/mock/esb/api}")
|
|
||||||
private String mciTargetUrl;
|
|
||||||
|
|
||||||
|
|
||||||
|
// Glow 기반의 LicoMciComponent 주입
|
||||||
|
private final LicoMciComponent mci;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AI Agent가 호출하게 될 메서드입니다.
|
* AI Agent가 호출하게 될 메서드입니다.
|
||||||
@@ -50,31 +44,24 @@ public class OnnbaMciToolService {
|
|||||||
displayName = "보종By가입설계한도계산조회",
|
displayName = "보종By가입설계한도계산조회",
|
||||||
description = "MCI 연동을 통해 보종By가입설계한도계산조회를 수행합니다.",
|
description = "MCI 연동을 통해 보종By가입설계한도계산조회를 수행합니다.",
|
||||||
prompt = "가입설계 한도를 계산하고 조회해줘.",
|
prompt = "가입설계 한도를 계산하고 조회해줘.",
|
||||||
mappingId = "CLCNNB00001"
|
mappingId = INTERFACE_CODE_3011
|
||||||
)
|
)
|
||||||
public Object callOnnba3011(Onnba3011ReqDto req) {
|
public Object callOnnba3011(Onnba3011ReqDto req) {
|
||||||
log.info("[MCI Tool] 보종By가입설계한도계산조회 요청 수신.");
|
log.info("[MCI Tool] 보종By가입설계한도계산조회 요청 수신.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 1. MCI 전문 통신을 위한 통합 Wrapper 객체 생성
|
// GlowMciComponent 표준 방식 (Transfer 객체 이용)
|
||||||
MciRequestWrapper<Onnba3011ReqDto> wrapper = new MciRequestWrapper<>();
|
Transfer<Object> resTransfer = mci.callTo(
|
||||||
|
INTERFACE_CODE_3011,
|
||||||
|
null, // rcvSvcId
|
||||||
|
req,
|
||||||
|
Object.class
|
||||||
|
);
|
||||||
|
|
||||||
// 2. 공통 헤더 세팅
|
log.info("[MCI Tool] Glow 기반 MCI 연동 성공.");
|
||||||
ShinhanCommonHeaderDto header = new ShinhanCommonHeaderDto();
|
|
||||||
header.setItrIfId("CLCNNB00001");
|
|
||||||
wrapper.setTgrmCmnnhddValu(header);
|
|
||||||
|
|
||||||
// 3. 비즈니스 데이터(Body) 세팅
|
// 결과 반환 (실제로는 resTransfer.getBody() 리턴)
|
||||||
wrapper.setBody(req);
|
return resTransfer.getBody() != null ? resTransfer.getBody() : "{\"status\":\"SUCCESS\", \"message\":\"GlowMciComponent 통신 완료\"}";
|
||||||
|
|
||||||
// 4. ShinhanMciSender를 통해 통합 JSON 연동 수행 및 응답 수신
|
|
||||||
log.info("[MCI Tool] ShinhanMciSender 연동 시작... (URL: {})", mciTargetUrl);
|
|
||||||
String responseJson = shinhanMciSender.send(mciTargetUrl, wrapper);
|
|
||||||
|
|
||||||
log.info("[MCI Tool] MCI 연동 성공.");
|
|
||||||
|
|
||||||
// 결과 반환
|
|
||||||
return responseJson;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[MCI Tool] MCI 연동 중 오류 발생: {}", e.getMessage(), e);
|
log.error("[MCI Tool] MCI 연동 중 오류 발생: {}", e.getMessage(), e);
|
||||||
|
|||||||
35
mci_sample_test.http
Normal file
35
mci_sample_test.http
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
### 대내 MCI 샘플 툴(send_mci_sample) 테스트
|
||||||
|
# 이 스크립트는 IntelliJ IDEA의 HTTP Client 플러그인을 위한 테스트 파일입니다.
|
||||||
|
# 1. 서버(Gateway 및 Tool 모듈)를 먼저 실행해 주세요.
|
||||||
|
# 2. 아래 초록색 플레이(▶) 버튼을 누르면 툴 함수가 호출됩니다!
|
||||||
|
|
||||||
|
POST http://localhost:8081/mcp/api/v1/tools/call
|
||||||
|
Content-Type: application/json
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": "test-1234",
|
||||||
|
"params": {
|
||||||
|
"name": "other_send_mci_sample",
|
||||||
|
"arguments": {
|
||||||
|
"tgrmCmnnhddValu": {
|
||||||
|
"envrTypeCd": "D",
|
||||||
|
"itrIfId": "IF_TEST_001"
|
||||||
|
},
|
||||||
|
"tgrmMsdvValu": {
|
||||||
|
"msgHddvValu": {
|
||||||
|
"msgTnsmTypeCd": "0"
|
||||||
|
},
|
||||||
|
"msgDtdvValu": {
|
||||||
|
"msgCd": "0000"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tgrmDtdvValu": {
|
||||||
|
"customerName": "홍길동",
|
||||||
|
"targetDate": "20260901",
|
||||||
|
"remarks": "MCI 연동 테스트"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user