forked from kimhyungsik/ax_hub_mcp_tool
refactor: apply Legacy naming convention to Sms and Sample converters and DTOs
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
package io.shinhanlife.axhub.biz.mcp.sample.converter;
|
||||
|
||||
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleAiReqDto;
|
||||
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleMciReqDto;
|
||||
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleLegacyReqDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface SampleMciConverter {
|
||||
public interface SampleLegacyConverter {
|
||||
|
||||
// 테스트 환경 등에서 Spring Bean 주입 없이 직접 접근하기 위한 INSTANCE 제공 (IDE 에러 방지용)
|
||||
SampleMciConverter INSTANCE = Mappers.getMapper(SampleMciConverter.class);
|
||||
SampleLegacyConverter INSTANCE = Mappers.getMapper(SampleLegacyConverter.class);
|
||||
|
||||
/**
|
||||
* AI Agent의 DTO를 MCI 통신용 DTO로 변환합니다.
|
||||
@@ -19,5 +19,5 @@ public interface SampleMciConverter {
|
||||
@Mapping(source = "userId", target = "customerId")
|
||||
@Mapping(source = "actionType", target = "interfaceId")
|
||||
@Mapping(source = "extraInfo", target = "requestDetails")
|
||||
SampleMciReqDto toMciReq(SampleAiReqDto aiReq);
|
||||
SampleLegacyReqDto toLegacyReq(SampleAiReqDto aiReq);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import lombok.ToString;
|
||||
@ToString
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@AllArgsConstructor
|
||||
public class SampleMciReqDto {
|
||||
public class SampleLegacyReqDto {
|
||||
|
||||
/**
|
||||
* MCI 인터페이스 ID (예: MCI0001)
|
||||
@@ -1,17 +1,17 @@
|
||||
package io.shinhanlife.axhub.biz.mcp.sample.converter;
|
||||
|
||||
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleAiReqDto;
|
||||
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleMciReqDto;
|
||||
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleLegacyReqDto;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
public class SampleMciConverterTest {
|
||||
public class SampleLegacyConverterTest {
|
||||
|
||||
// MapStruct가 자동 생성한 구현체를 가져와서 테스트합니다. (IDE 에러 방지를 위해 INSTANCE 참조)
|
||||
private final SampleMciConverter sampleMciConverter = SampleMciConverter.INSTANCE;
|
||||
private final SampleLegacyConverter sampleLegacyConverter = SampleLegacyConverter.INSTANCE;
|
||||
|
||||
@Test
|
||||
@DisplayName("AI 파라미터 DTO가 MCI DTO로 정확히 매핑되는지 테스트")
|
||||
@@ -24,12 +24,12 @@ public class SampleMciConverterTest {
|
||||
.build();
|
||||
|
||||
// when: MapStruct 자동 생성 매퍼를 통해 1줄로 변환
|
||||
SampleMciReqDto mciDto = sampleMciConverter.toMciReq(aiDto);
|
||||
SampleLegacyReqDto mciDto = sampleLegacyConverter.toLegacyReq(aiDto);
|
||||
|
||||
// then: 콘솔에 결과 출력 및 값 검증
|
||||
System.out.println("====== MapStruct 변환 테스트 결과 ======");
|
||||
System.out.println(" [변환 전] AI DTO : " + aiDto);
|
||||
System.out.println(" [변환 후] MCI DTO: " + mciDto);
|
||||
System.out.println(" [변환 후] Legacy DTO: " + mciDto);
|
||||
System.out.println("===============================================");
|
||||
|
||||
assertNotNull(mciDto, "변환된 객체는 null이 아니어야 합니다.");
|
||||
@@ -7,11 +7,11 @@ import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface SmsMciConverter {
|
||||
public interface SmsLegacyConverter {
|
||||
|
||||
SmsMciConverter INSTANCE = Mappers.getMapper(SmsMciConverter.class);
|
||||
SmsLegacyConverter INSTANCE = Mappers.getMapper(SmsLegacyConverter.class);
|
||||
|
||||
@Mapping(source = "phoneNumber", target = "phone")
|
||||
@Mapping(source = "message", target = "content")
|
||||
SmsLegacyReqDto toMciReq(SmsSendReq req);
|
||||
SmsLegacyReqDto toLegacyReq(SmsSendReq req);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import io.shinhanlife.axhub.biz.mcp.tool.annotation.McpFunction;
|
||||
import io.shinhanlife.axhub.biz.mcp.tool.annotation.McpTool;
|
||||
import io.shinhanlife.axhub.biz.mcp.tool.dto.SmsSendReq;
|
||||
import io.shinhanlife.axhub.biz.mcp.tool.service.AbstractMcpToolService;
|
||||
import io.shinhanlife.axhub.biz.mcp.tool.sms.converter.SmsMciConverter;
|
||||
import io.shinhanlife.axhub.biz.mcp.tool.sms.converter.SmsLegacyConverter;
|
||||
import io.shinhanlife.axhub.biz.mcp.tool.sms.dto.SmsLegacyReqDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -33,10 +33,10 @@ public class SmsToolService extends AbstractMcpToolService {
|
||||
log.info("[SMS] SMS 발송 요청 수신. 수신자: {}", req.getPhoneNumber());
|
||||
|
||||
// MapStruct를 이용한 자동 매핑 (AI DTO -> MCI DTO)
|
||||
SmsLegacyReqDto mciReq = SmsMciConverter.INSTANCE.toMciReq(req);
|
||||
SmsLegacyReqDto legacyReq = SmsLegacyConverter.INSTANCE.toLegacyReq(req);
|
||||
|
||||
// 레거시 시스템 연동 (EAI) - DTO 객체를 그대로 넘김
|
||||
Map<String, Object> result = executeLegacy("EAI", "SMS_SEND_001", mciReq);
|
||||
Map<String, Object> result = executeLegacy("EAI", "SMS_SEND_001", legacyReq);
|
||||
|
||||
// 결과 가공
|
||||
if ("SUCCESS".equals(result.get("status"))) {
|
||||
|
||||
Reference in New Issue
Block a user