|
|
|
|
@@ -167,9 +167,9 @@ public class ToolScaffolder {
|
|
|
|
|
String moduleName, StringBuilder log) throws IOException {
|
|
|
|
|
String baseName = toPascalCase(tool.baseName());
|
|
|
|
|
boolean mci = "MCI".equalsIgnoreCase(tool.routingType());
|
|
|
|
|
String code = mci ? tool.clientSystemCode().toLowerCase(Locale.ROOT) : toPackageSegment(tool.httpApiName());
|
|
|
|
|
String ioPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." : ".infra.itrf.http.") + code;
|
|
|
|
|
Path clientDir = sourceRoot.resolve(Paths.get("infra", "itrf", mci ? "mci" : "http", code));
|
|
|
|
|
String codePath = mci ? (tool.clientSystemCode().length() == 4 ? tool.clientSystemCode().substring(0, 3).toLowerCase(Locale.ROOT) + "/" + tool.clientSystemCode().substring(3).toLowerCase(Locale.ROOT) : tool.clientSystemCode().toLowerCase(Locale.ROOT)) : toPackageSegment(tool.httpApiName());
|
|
|
|
|
String ioPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." : ".infra.itrf.http.") + codePath.replace("/", ".");
|
|
|
|
|
Path clientDir = sourceRoot.resolve(Paths.get("infra", "itrf", mci ? "mci" : "http", codePath.replace("/", "\\\\")));
|
|
|
|
|
Path ioDir = clientDir.resolve("io");
|
|
|
|
|
Files.createDirectories(ioDir);
|
|
|
|
|
writeUtf8(dtoDir.resolve(baseName + "Request.java"),
|
|
|
|
|
@@ -180,13 +180,26 @@ public class ToolScaffolder {
|
|
|
|
|
writeStructuredFieldTypes(dtoDir, bizPackage + ".dto", baseName + "Response", tool.outputFields());
|
|
|
|
|
if (mci) {
|
|
|
|
|
writeUtf8(ioDir.resolve(baseName + "_I.java"),
|
|
|
|
|
mciIoContent("infra.itrf.mci." + code, baseName + "_I", tool.inputFields(), "", ""));
|
|
|
|
|
mciIoContent("infra.itrf.mci." + codePath.replace("/", "."), baseName + "_I", tool.inputFields(), "", ""));
|
|
|
|
|
writeUtf8(ioDir.resolve(baseName + "_O.java"),
|
|
|
|
|
mciIoContent("infra.itrf.mci." + code, baseName + "_O", tool.outputFields(), "", ""));
|
|
|
|
|
mciIoContent("infra.itrf.mci." + codePath.replace("/", "."), baseName + "_O", tool.outputFields(), "", ""));
|
|
|
|
|
writeStructuredFieldTypes(ioDir, ioPackage + ".io", baseName + "_I", tool.inputFields());
|
|
|
|
|
writeStructuredFieldTypes(ioDir, ioPackage + ".io", baseName + "_O", tool.outputFields());
|
|
|
|
|
writeUtf8(clientDir.resolve(baseName + "Client.java"),
|
|
|
|
|
groupedMciClientContent(ioPackage, baseName, tool.interfaceId()));
|
|
|
|
|
String clientPrefixCap = toPascalCase(tool.clientSystemCode());
|
|
|
|
|
Path mciClientFile = clientDir.resolve("Mci" + clientPrefixCap + "Client.java");
|
|
|
|
|
if (!java.nio.file.Files.exists(mciClientFile)) {
|
|
|
|
|
String mciClientContent = "package " + ioPackage + ";\n\n"
|
|
|
|
|
+ "import org.springframework.stereotype.Component;\n"
|
|
|
|
|
+ "import lombok.RequiredArgsConstructor;\n"
|
|
|
|
|
+ "import io.shinhanlife.dap.lib.integration.mci.component.AxhubMciComponent;\n"
|
|
|
|
|
+ "import io.shinhanlife.glow.communication.dto.Transfer;\n\n"
|
|
|
|
|
+ "@Component\n@RequiredArgsConstructor\npublic class Mci" + clientPrefixCap + "Client {\n"
|
|
|
|
|
+ " private final AxhubMciComponent mci;\n"
|
|
|
|
|
+ " public <O> Transfer<O> callTo(String interfaceId, String dummy, Object mciReq, Class<O> resType) throws Exception {\n"
|
|
|
|
|
+ " return mci.callTo(interfaceId, dummy, mciReq, resType);\n"
|
|
|
|
|
+ " }\n}\n";
|
|
|
|
|
writeUtf8(mciClientFile, mciClientContent);
|
|
|
|
|
}
|
|
|
|
|
writeUtf8(sourceRoot.resolve(Paths.get("biz", tool.group().toLowerCase(Locale.ROOT), "converter", baseName + "Converter.java")),
|
|
|
|
|
groupedMciConverterContent(bizPackage, baseName, ioPackage));
|
|
|
|
|
} else {
|
|
|
|
|
@@ -280,7 +293,9 @@ public class ToolScaffolder {
|
|
|
|
|
clientVariable = Character.toLowerCase(baseName.charAt(0)) + baseName.substring(1) + "Client";
|
|
|
|
|
}
|
|
|
|
|
String converterVariable = Character.toLowerCase(baseName.charAt(0)) + baseName.substring(1) + "Converter";
|
|
|
|
|
String integrationPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." + tool.clientSystemCode().toLowerCase(Locale.ROOT)
|
|
|
|
|
String integrationSysCode = tool.clientSystemCode().toLowerCase(Locale.ROOT);
|
|
|
|
|
String sysCodePath = integrationSysCode.length() == 4 ? integrationSysCode.substring(0, 3) + "." + integrationSysCode.substring(3) : integrationSysCode;
|
|
|
|
|
String integrationPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." + sysCodePath
|
|
|
|
|
: ".infra.itrf.http." + toPackageSegment(tool.httpApiName()));
|
|
|
|
|
imports.append("import ").append(bizPackage).append(".dto.").append(baseName).append("Request;\n")
|
|
|
|
|
.append("import ").append(bizPackage).append(".dto.").append(baseName).append("Response;\n")
|
|
|
|
|
@@ -298,7 +313,7 @@ public class ToolScaffolder {
|
|
|
|
|
.append("(").append(baseName).append("Request req) {\n")
|
|
|
|
|
.append(" ").append(baseName).append(mci ? "_I" : "HttpRequest").append(" request = ").append(converterVariable).append(".toRequest(req);\n")
|
|
|
|
|
.append(" ").append(baseName).append(mci ? "_O" : "HttpResponse").append(" response = ").append(clientVariable)
|
|
|
|
|
.append(mci ? ".call(\"" + tool.interfaceId() + "\", request, " + baseName + "_O.class);\n" : ".call(request, " + baseName + "HttpResponse.class);\n")
|
|
|
|
|
.append(mci ? ".callTo(\"" + tool.interfaceId() + "\", null, request, " + baseName + "_O.class).getBody();\n" : ".call(request, " + baseName + "HttpResponse.class);\n")
|
|
|
|
|
.append(" ").append(baseName).append("Response toolResponse = ").append(converterVariable).append(".toResponse(response);\n")
|
|
|
|
|
.append(" if (toolResponse == null) toolResponse = new ").append(baseName).append("Response();\n")
|
|
|
|
|
.append(" toolResponse.setResultCode(\"SUCCESS\");\n")
|
|
|
|
|
@@ -360,7 +375,9 @@ public class ToolScaffolder {
|
|
|
|
|
throw new IllegalArgumentException("Tool method or MCP Tool name already exists: " + methodName);
|
|
|
|
|
}
|
|
|
|
|
boolean mci = "MCI".equalsIgnoreCase(tool.routingType());
|
|
|
|
|
String integrationPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." + tool.clientSystemCode().toLowerCase(Locale.ROOT)
|
|
|
|
|
String integrationSysCode = tool.clientSystemCode().toLowerCase(Locale.ROOT);
|
|
|
|
|
String sysCodePath = integrationSysCode.length() == 4 ? integrationSysCode.substring(0, 3) + "." + integrationSysCode.substring(3) : integrationSysCode;
|
|
|
|
|
String integrationPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." + sysCodePath
|
|
|
|
|
: ".infra.itrf.http." + toPackageSegment(tool.httpApiName()));
|
|
|
|
|
String requestType = baseName + "Request";
|
|
|
|
|
String responseType = baseName + "Response";
|
|
|
|
|
@@ -645,7 +662,7 @@ public class ToolScaffolder {
|
|
|
|
|
Path mciClientDir = null;
|
|
|
|
|
|
|
|
|
|
if (isMci && clientSystemCode != null && clientSystemCode.length() == 4) {
|
|
|
|
|
String clientPrefix = clientSystemCode.toLowerCase();
|
|
|
|
|
String clientPrefix = clientSystemCode.length() == 4 ? clientSystemCode.substring(0,3).toLowerCase() + "/" + clientSystemCode.substring(3).toLowerCase() : clientSystemCode.toLowerCase();
|
|
|
|
|
clientPrefixCap = toPascalCase(clientSystemCode);
|
|
|
|
|
mciGroupPath = "infra/itrf/mci/" + clientPrefix;
|
|
|
|
|
mciClientDir = rootDir.resolve(Paths.get(moduleName, BASE_PACKAGE_PATH, mciGroupPath));
|
|
|
|
|
@@ -777,8 +794,8 @@ public class ToolScaffolder {
|
|
|
|
|
examples = List.of(title + " 정보를 보여줘", title + " 확인해줘", "현재 " + title + " 알려줘");
|
|
|
|
|
}
|
|
|
|
|
sb.append(" exampleQueries = {")
|
|
|
|
|
.append(examples.stream().map(q -> "\"" + javaText(q) + "\"").collect(Collectors.joining(", ")))
|
|
|
|
|
.append("},\n");
|
|
|
|
|
.append(examples.stream().map(q -> "\"" + javaText(q) + "\"").collect(Collectors.joining(", ")))
|
|
|
|
|
.append("},\n");
|
|
|
|
|
|
|
|
|
|
sb.append(" destructive = ").append(isMutation).append(",\n");
|
|
|
|
|
sb.append(" idempotent = ").append(!isMutation).append(",\n");
|
|
|
|
|
@@ -788,8 +805,8 @@ public class ToolScaffolder {
|
|
|
|
|
tags = List.of(group.toLowerCase(Locale.ROOT), isMutation ? "처리" : "조회");
|
|
|
|
|
}
|
|
|
|
|
sb.append(" tags = {")
|
|
|
|
|
.append(tags.stream().map(t -> "\"" + javaText(t) + "\"").collect(Collectors.joining(", ")))
|
|
|
|
|
.append("},\n");
|
|
|
|
|
.append(tags.stream().map(t -> "\"" + javaText(t) + "\"").collect(Collectors.joining(", ")))
|
|
|
|
|
.append("},\n");
|
|
|
|
|
|
|
|
|
|
sb.append(" ownerOrg = \"").append(javaText(definitionOptions.ownerOrg() != null && !definitionOptions.ownerOrg().isBlank() ? definitionOptions.ownerOrg() : "MCP_TOOL")).append("\"\n");
|
|
|
|
|
sb.append(" )");
|
|
|
|
|
|