forked from kimhyungsik/ax_hub_mcp_tool
소스 수정 완료
This commit is contained in:
@@ -90,12 +90,12 @@ public class ToolScaffolder {
|
|||||||
|
|
||||||
String shortName = moduleName.replace("axhub-tool-", "").replace("-", "");
|
String shortName = moduleName.replace("axhub-tool-", "").replace("-", "");
|
||||||
Path legacyDtoDir = rootDir.resolve(Paths.get(moduleName, BASE_PACKAGE_PATH, shortName, "dto"));
|
Path legacyDtoDir = rootDir.resolve(Paths.get(moduleName, BASE_PACKAGE_PATH, shortName, "dto"));
|
||||||
Path mapperDir = rootDir.resolve(Paths.get(moduleName, BASE_PACKAGE_PATH, shortName, "mapper"));
|
Path converterDir = rootDir.resolve(Paths.get(moduleName, BASE_PACKAGE_PATH, shortName, "converter"));
|
||||||
|
|
||||||
Files.createDirectories(serviceDir);
|
Files.createDirectories(serviceDir);
|
||||||
Files.createDirectories(dtoDir);
|
Files.createDirectories(dtoDir);
|
||||||
Files.createDirectories(legacyDtoDir);
|
Files.createDirectories(legacyDtoDir);
|
||||||
Files.createDirectories(mapperDir);
|
Files.createDirectories(converterDir);
|
||||||
|
|
||||||
StringBuilder log = new StringBuilder();
|
StringBuilder log = new StringBuilder();
|
||||||
|
|
||||||
@@ -275,9 +275,9 @@ public class ToolScaffolder {
|
|||||||
""".formatted(BASE_PACKAGE, shortName, BASE_PACKAGE, shortName, baseName, author, createDate, createDate, author, baseName);
|
""".formatted(BASE_PACKAGE, shortName, BASE_PACKAGE, shortName, baseName, author, createDate, createDate, author, baseName);
|
||||||
Files.writeString(legacyDtoDir.resolve(baseName + "MciResDto.java"), legacyResContent);
|
Files.writeString(legacyDtoDir.resolve(baseName + "MciResDto.java"), legacyResContent);
|
||||||
|
|
||||||
// Generate MCI Mapper
|
// Generate MCI Converter
|
||||||
String mapperContent = """
|
String converterContent = """
|
||||||
package %s.%s.mapper;
|
package %s.%s.converter;
|
||||||
|
|
||||||
import %s.dto.%sReq;
|
import %s.dto.%sReq;
|
||||||
import %s.dto.%sRes;
|
import %s.dto.%sRes;
|
||||||
@@ -288,8 +288,8 @@ public class ToolScaffolder {
|
|||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package %s.%s.mapper
|
* @package %s.%s.converter
|
||||||
* @className %sMciMapper
|
* @className %sMciConverter
|
||||||
* @description AX HUB 시스템 처리 클래스
|
* @description AX HUB 시스템 처리 클래스
|
||||||
* @author %s
|
* @author %s
|
||||||
* @create %s
|
* @create %s
|
||||||
@@ -302,9 +302,9 @@ public class ToolScaffolder {
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface %sMciMapper {
|
public interface %sMciConverter {
|
||||||
|
|
||||||
%sMciMapper INSTANCE = Mappers.getMapper(%sMciMapper.class);
|
%sMciConverter INSTANCE = Mappers.getMapper(%sMciConverter.class);
|
||||||
|
|
||||||
// @Mapping(source = "sourceField", target = "targetField")
|
// @Mapping(source = "sourceField", target = "targetField")
|
||||||
%sMciReqDto toMciReq(%sReq req);
|
%sMciReqDto toMciReq(%sReq req);
|
||||||
@@ -320,7 +320,7 @@ public class ToolScaffolder {
|
|||||||
BASE_PACKAGE, shortName, baseName, author, createDate, createDate, author,
|
BASE_PACKAGE, shortName, baseName, author, createDate, createDate, author,
|
||||||
baseName, baseName, baseName, baseName, baseName, baseName, baseName
|
baseName, baseName, baseName, baseName, baseName, baseName, baseName
|
||||||
);
|
);
|
||||||
Files.writeString(mapperDir.resolve(baseName + "MciMapper.java"), mapperContent);
|
Files.writeString(converterDir.resolve(baseName + "MciConverter.java"), converterContent);
|
||||||
|
|
||||||
log.append("\n=========================================\n");
|
log.append("\n=========================================\n");
|
||||||
log.append(" Scaffolding Complete!\n");
|
log.append(" Scaffolding Complete!\n");
|
||||||
@@ -330,7 +330,7 @@ public class ToolScaffolder {
|
|||||||
log.append("[Res DTO] ").append(dtoDir.resolve(baseName + "Res.java")).append("\n");
|
log.append("[Res DTO] ").append(dtoDir.resolve(baseName + "Res.java")).append("\n");
|
||||||
log.append("[MCI Req DTO] ").append(legacyDtoDir.resolve(baseName + "MciReqDto.java")).append("\n");
|
log.append("[MCI Req DTO] ").append(legacyDtoDir.resolve(baseName + "MciReqDto.java")).append("\n");
|
||||||
log.append("[MCI Res DTO] ").append(legacyDtoDir.resolve(baseName + "MciResDto.java")).append("\n");
|
log.append("[MCI Res DTO] ").append(legacyDtoDir.resolve(baseName + "MciResDto.java")).append("\n");
|
||||||
log.append("[MCI Mapper] ").append(mapperDir.resolve(baseName + "MciMapper.java")).append("\n");
|
log.append("[MCI Converter] ").append(converterDir.resolve(baseName + "MciConverter.java")).append("\n");
|
||||||
log.append("\n Tip: ").append(interfaceId).append(" 목업 데이터를 mock-responses.json에 추가하세요.\n");
|
log.append("\n Tip: ").append(interfaceId).append(" 목업 데이터를 mock-responses.json에 추가하세요.\n");
|
||||||
|
|
||||||
return log.toString();
|
return log.toString();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package io.shinhanlife.axhub.biz.mcp.sample.mapper;
|
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.SampleAiReqDto;
|
||||||
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleMciReqDto;
|
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleMciReqDto;
|
||||||
@@ -7,10 +7,10 @@ import org.mapstruct.Mapping;
|
|||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface SampleMciMapper {
|
public interface SampleMciConverter {
|
||||||
|
|
||||||
// 테스트 환경 등에서 Spring Bean 주입 없이 직접 접근하기 위한 INSTANCE 제공 (IDE 에러 방지용)
|
// 테스트 환경 등에서 Spring Bean 주입 없이 직접 접근하기 위한 INSTANCE 제공 (IDE 에러 방지용)
|
||||||
SampleMciMapper INSTANCE = Mappers.getMapper(SampleMciMapper.class);
|
SampleMciConverter INSTANCE = Mappers.getMapper(SampleMciConverter.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AI Agent의 DTO를 MCI 통신용 DTO로 변환합니다.
|
* AI Agent의 DTO를 MCI 통신용 DTO로 변환합니다.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package io.shinhanlife.axhub.biz.mcp.sample.mapper;
|
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.SampleAiReqDto;
|
||||||
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleMciReqDto;
|
import io.shinhanlife.axhub.biz.mcp.sample.dto.SampleMciReqDto;
|
||||||
@@ -8,10 +8,10 @@ import org.junit.jupiter.api.Test;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class SampleMciMapperTest {
|
public class SampleMciConverterTest {
|
||||||
|
|
||||||
// MapStruct가 자동 생성한 구현체를 가져와서 테스트합니다. (IDE 에러 방지를 위해 INSTANCE 참조)
|
// MapStruct가 자동 생성한 구현체를 가져와서 테스트합니다. (IDE 에러 방지를 위해 INSTANCE 참조)
|
||||||
private final SampleMciMapper sampleMciMapper = SampleMciMapper.INSTANCE;
|
private final SampleMciConverter sampleMciConverter = SampleMciConverter.INSTANCE;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("AI 파라미터 DTO가 MCI DTO로 정확히 매핑되는지 테스트")
|
@DisplayName("AI 파라미터 DTO가 MCI DTO로 정확히 매핑되는지 테스트")
|
||||||
@@ -24,7 +24,7 @@ public class SampleMciMapperTest {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// when: MapStruct 자동 생성 매퍼를 통해 1줄로 변환
|
// when: MapStruct 자동 생성 매퍼를 통해 1줄로 변환
|
||||||
SampleMciReqDto mciDto = sampleMciMapper.toMciReq(aiDto);
|
SampleMciReqDto mciDto = sampleMciConverter.toMciReq(aiDto);
|
||||||
|
|
||||||
// then: 콘솔에 결과 출력 및 값 검증
|
// then: 콘솔에 결과 출력 및 값 검증
|
||||||
System.out.println("====== MapStruct 변환 테스트 결과 ======");
|
System.out.println("====== MapStruct 변환 테스트 결과 ======");
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package io.shinhanlife.axhub.biz.mcp.tool.hr.mapper;
|
package io.shinhanlife.axhub.biz.mcp.tool.hr.converter;
|
||||||
|
|
||||||
import io.shinhanlife.axhub.biz.mcp.tool.dto.SearchDetailHrReq;
|
import io.shinhanlife.axhub.biz.mcp.tool.dto.SearchDetailHrReq;
|
||||||
import io.shinhanlife.axhub.biz.mcp.tool.dto.SearchDetailHrRes;
|
import io.shinhanlife.axhub.biz.mcp.tool.dto.SearchDetailHrRes;
|
||||||
@@ -9,8 +9,8 @@ import org.mapstruct.Mapping;
|
|||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package io.shinhanlife.axhub.biz.mcp.tool.hr.mapper
|
* @package io.shinhanlife.axhub.biz.mcp.tool.hr.converter
|
||||||
* @className SearchDetailHrMciMapper
|
* @className SearchDetailHrMciConverter
|
||||||
* @description AX HUB 시스템 처리 클래스
|
* @description AX HUB 시스템 처리 클래스
|
||||||
* @author root
|
* @author root
|
||||||
* @create 2026.07.13
|
* @create 2026.07.13
|
||||||
@@ -23,9 +23,9 @@ import org.mapstruct.factory.Mappers;
|
|||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface SearchDetailHrMciMapper {
|
public interface SearchDetailHrMciConverter {
|
||||||
|
|
||||||
SearchDetailHrMciMapper INSTANCE = Mappers.getMapper(SearchDetailHrMciMapper.class);
|
SearchDetailHrMciConverter INSTANCE = Mappers.getMapper(SearchDetailHrMciConverter.class);
|
||||||
|
|
||||||
// @Mapping(source = "sourceField", target = "targetField")
|
// @Mapping(source = "sourceField", target = "targetField")
|
||||||
SearchDetailHrMciReqDto toMciReq(SearchDetailHrReq req);
|
SearchDetailHrMciReqDto toMciReq(SearchDetailHrReq req);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package io.shinhanlife.axhub.biz.mcp.tool.sms.mapper;
|
package io.shinhanlife.axhub.biz.mcp.tool.sms.converter;
|
||||||
|
|
||||||
import io.shinhanlife.axhub.biz.mcp.tool.dto.SmsSendReq;
|
import io.shinhanlife.axhub.biz.mcp.tool.dto.SmsSendReq;
|
||||||
import io.shinhanlife.axhub.biz.mcp.tool.sms.dto.SmsMciReqDto;
|
import io.shinhanlife.axhub.biz.mcp.tool.sms.dto.SmsMciReqDto;
|
||||||
@@ -7,9 +7,9 @@ import org.mapstruct.Mapping;
|
|||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper(componentModel = "spring")
|
@Mapper(componentModel = "spring")
|
||||||
public interface SmsMciMapper {
|
public interface SmsMciConverter {
|
||||||
|
|
||||||
SmsMciMapper INSTANCE = Mappers.getMapper(SmsMciMapper.class);
|
SmsMciConverter INSTANCE = Mappers.getMapper(SmsMciConverter.class);
|
||||||
|
|
||||||
@Mapping(source = "phoneNumber", target = "phone")
|
@Mapping(source = "phoneNumber", target = "phone")
|
||||||
@Mapping(source = "message", target = "content")
|
@Mapping(source = "message", target = "content")
|
||||||
@@ -5,7 +5,7 @@ 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.dto.SmsSendReq;
|
||||||
import io.shinhanlife.axhub.biz.mcp.tool.service.AbstractMcpToolService;
|
import io.shinhanlife.axhub.biz.mcp.tool.service.AbstractMcpToolService;
|
||||||
import io.shinhanlife.axhub.biz.mcp.tool.sms.dto.SmsMciReqDto;
|
import io.shinhanlife.axhub.biz.mcp.tool.sms.dto.SmsMciReqDto;
|
||||||
import io.shinhanlife.axhub.biz.mcp.tool.sms.mapper.SmsMciMapper;
|
import io.shinhanlife.axhub.biz.mcp.tool.sms.converter.SmsMciConverter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -33,7 +33,7 @@ public class SmsToolService extends AbstractMcpToolService {
|
|||||||
log.info("[SMS] SMS 발송 요청 수신. 수신자: {}", req.getPhoneNumber());
|
log.info("[SMS] SMS 발송 요청 수신. 수신자: {}", req.getPhoneNumber());
|
||||||
|
|
||||||
// MapStruct를 이용한 자동 매핑 (AI DTO -> MCI DTO)
|
// MapStruct를 이용한 자동 매핑 (AI DTO -> MCI DTO)
|
||||||
SmsMciReqDto mciReq = SmsMciMapper.INSTANCE.toMciReq(req);
|
SmsMciReqDto mciReq = SmsMciConverter.INSTANCE.toMciReq(req);
|
||||||
|
|
||||||
// 레거시 시스템 연동 (EAI) - DTO 객체를 그대로 넘김
|
// 레거시 시스템 연동 (EAI) - DTO 객체를 그대로 넘김
|
||||||
Map<String, Object> result = executeLegacy("EAI", "SMS_SEND_001", mciReq);
|
Map<String, Object> result = executeLegacy("EAI", "SMS_SEND_001", mciReq);
|
||||||
|
|||||||
Reference in New Issue
Block a user