forked from kimhyungsik/ax_hub_mcp_tool
fix(scaffold): format 4-char MCI system code paths (e.g. hmc.i) and unify grouped tool client
All checks were successful
Deploy Tools / deploy (push) Successful in 2m23s
All checks were successful
Deploy Tools / deploy (push) Successful in 2m23s
- For 4-character client system codes like 'hmci', the path is now split as 'hmc/i' to generate packages like 'hmc.i' - MultiTool UseCase scaffolding now correctly reuses the shared Mci[Prefix]Client (e.g. MciHmciClient) instead of generating separate tool-specific clients
This commit is contained in:
@@ -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,8 +293,10 @@ 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)
|
||||
: ".infra.itrf.http." + toPackageSegment(tool.httpApiName()));
|
||||
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")
|
||||
.append("import ").append(bizPackage).append(".converter.").append(baseName).append("Converter;\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,8 +375,10 @@ 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)
|
||||
: ".infra.itrf.http." + toPackageSegment(tool.httpApiName()));
|
||||
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";
|
||||
String requestIo = baseName + (mci ? "_I" : "HttpRequest");
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user