From d1056f74b66b4e19b16102612c97080c871a140d Mon Sep 17 00:00:00 2001 From: jade Date: Wed, 8 Jul 2026 15:09:13 +0900 Subject: [PATCH] feat: Add MciCall sample implementation --- .../biz/mcp/sample/dto/SampleMciReqDto.java | 31 +++++++++++ .../biz/mcp/sample/dto/SampleMciResDto.java | 33 ++++++++++++ .../sample/service/SampleMciCallService.java | 52 +++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/dto/SampleMciReqDto.java create mode 100644 axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/dto/SampleMciResDto.java create mode 100644 axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/service/SampleMciCallService.java diff --git a/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/dto/SampleMciReqDto.java b/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/dto/SampleMciReqDto.java new file mode 100644 index 0000000..09d24cf --- /dev/null +++ b/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/dto/SampleMciReqDto.java @@ -0,0 +1,31 @@ +package io.shinhanlife.axhub.biz.mcp.sample.dto; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@Getter +@Builder +@ToString +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class SampleMciReqDto { + + /** + * MCI 인터페이스 ID (예: MCI0001) + */ + private String interfaceId; + + /** + * 고객 식별 번호 + */ + private String customerId; + + /** + * 요청 세부 파라미터 + */ + private String requestDetails; +} diff --git a/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/dto/SampleMciResDto.java b/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/dto/SampleMciResDto.java new file mode 100644 index 0000000..93d548b --- /dev/null +++ b/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/dto/SampleMciResDto.java @@ -0,0 +1,33 @@ +package io.shinhanlife.axhub.biz.mcp.sample.dto; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; + +import java.util.Map; + +@Getter +@Builder +@ToString +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +public class SampleMciResDto { + + /** + * 응답 코드 (예: "0000"이면 성공) + */ + private String resCode; + + /** + * 응답 메시지 + */ + private String resMsg; + + /** + * 상세 데이터 + */ + private Map data; +} diff --git a/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/service/SampleMciCallService.java b/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/service/SampleMciCallService.java new file mode 100644 index 0000000..8bbe5e0 --- /dev/null +++ b/axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/sample/service/SampleMciCallService.java @@ -0,0 +1,52 @@ +package io.shinhanlife.axhub.biz.mcp.sample.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.shinhanlife.axhub.biz.mcp.adapter.sender.EimsSender; +import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleMciReqDto; +import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleMciResDto; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class SampleMciCallService { + + private final EimsSender eimsSender; + private final ObjectMapper objectMapper; + + /** + * MCI 인터페이스를 호출하는 샘플 메서드 + * + * @param request MCI 호출을 위한 요청 데이터 + * @return MCI 서버의 응답 데이터 + */ + public SampleMciResDto callSampleMci(SampleMciReqDto request) { + log.info("📞 [MciCall] 시작 - Interface ID: {}", request.getInterfaceId()); + + try { + // 1. 요청 객체(DTO)를 JSON 문자열로 변환 (직렬화) + String payload = objectMapper.writeValueAsString(request); + log.debug("📤 [MciCall] 전송 페이로드: {}", payload); + + // 2. HTTP/2 기반의 EimsSender를 통해 실제 MCI 호출 + String responseJson = eimsSender.send(request.getInterfaceId(), payload); + log.debug("📥 [MciCall] 수신 응답 JSON: {}", responseJson); + + // 3. 수신받은 JSON 문자열을 응답 객체(DTO)로 역직렬화 후 반환 + SampleMciResDto response = objectMapper.readValue(responseJson, SampleMciResDto.class); + log.info("✅ [MciCall] 완료 - 응답 코드: {}", response.getResCode()); + + return response; + + } catch (JsonProcessingException e) { + log.error("❌ [MciCall] JSON 변환 중 오류 발생", e); + throw new RuntimeException("MCI 통신 중 JSON 파싱 오류", e); + } catch (Exception e) { + log.error("❌ [MciCall] 통신 중 오류 발생", e); + throw new RuntimeException("MCI 통신 실패", e); + } + } +}