fix: resolve mci package splitting and IO class naming issues in ToolScaffolder
All checks were successful
Deploy Tools / deploy (push) Successful in 2m25s

This commit is contained in:
jade
2026-08-20 13:04:06 +09:00
parent fdf9e91b0a
commit c9a04d031a

View File

@@ -167,9 +167,9 @@ public class ToolScaffolder {
String moduleName, StringBuilder log) throws IOException { String moduleName, StringBuilder log) throws IOException {
String baseName = toPascalCase(tool.baseName()); String baseName = toPascalCase(tool.baseName());
boolean mci = "MCI".equalsIgnoreCase(tool.routingType()); boolean mci = "MCI".equalsIgnoreCase(tool.routingType());
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 code = 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("/", "."); String ioPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." : ".infra.itrf.http.") + code.replace("/", ".");
Path clientDir = sourceRoot.resolve(Paths.get("infra", "itrf", mci ? "mci" : "http", codePath.replace("/", "\\\\"))); Path clientDir = sourceRoot.resolve(Paths.get("infra", "itrf", mci ? "mci" : "http", code));
Path ioDir = clientDir.resolve("io"); Path ioDir = clientDir.resolve("io");
Files.createDirectories(ioDir); Files.createDirectories(ioDir);
writeUtf8(dtoDir.resolve(baseName + "Request.java"), writeUtf8(dtoDir.resolve(baseName + "Request.java"),
@@ -180,26 +180,19 @@ public class ToolScaffolder {
writeStructuredFieldTypes(dtoDir, bizPackage + ".dto", baseName + "Response", tool.outputFields()); writeStructuredFieldTypes(dtoDir, bizPackage + ".dto", baseName + "Response", tool.outputFields());
if (mci) { if (mci) {
writeUtf8(ioDir.resolve(baseName + "_I.java"), writeUtf8(ioDir.resolve(baseName + "_I.java"),
mciIoContent("infra.itrf.mci." + codePath.replace("/", "."), baseName + "_I", tool.inputFields(), "", "")); mciIoContent("infra.itrf.mci." + code, baseName + "_I", tool.inputFields(), "", ""));
writeUtf8(ioDir.resolve(baseName + "_O.java"), writeUtf8(ioDir.resolve(baseName + "_O.java"),
mciIoContent("infra.itrf.mci." + codePath.replace("/", "."), baseName + "_O", tool.outputFields(), "", "")); mciIoContent("infra.itrf.mci." + code, baseName + "_O", tool.outputFields(), "", ""));
writeStructuredFieldTypes(ioDir, ioPackage + ".io", baseName + "_I", tool.inputFields()); writeStructuredFieldTypes(ioDir, ioPackage + ".io", tool.interfaceId() + "_I", tool.inputFields());
writeStructuredFieldTypes(ioDir, ioPackage + ".io", baseName + "_O", tool.outputFields()); writeStructuredFieldTypes(ioDir, ioPackage + ".io", tool.interfaceId() + "_O", tool.outputFields());
String clientPrefixCap = toPascalCase(tool.clientSystemCode()); String sysCode = tool.clientSystemCode();
Path mciClientFile = clientDir.resolve("Mci" + clientPrefixCap + "Client.java"); if (sysCode != null && sysCode.length() == 4) {
if (!java.nio.file.Files.exists(mciClientFile)) { String clientCap = toPascalCase(sysCode);
String mciClientContent = "package " + ioPackage + ";\n\n" writeUtf8(clientDir.resolve("Mci" + clientCap + "Client.java"),
+ "import org.springframework.stereotype.Component;\n" "package " + ioPackage + ";\n\nimport io.shinhanlife.dat.lib.integration.mci.component.AxhubMciComponent;\nimport io.shinhanlife.glow.communication.dto.Transfer;\nimport lombok.RequiredArgsConstructor;\nimport org.springframework.stereotype.Component;\n\n@Component\n@RequiredArgsConstructor\npublic class Mci" + clientCap + "Client {\n private final AxhubMciComponent mci;\n\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");
+ "import lombok.RequiredArgsConstructor;\n" } else {
+ "import io.shinhanlife.dat.lib.integration.mci.component.AxhubMciComponent;\n" writeUtf8(clientDir.resolve(baseName + "Client.java"), groupedMciClientContent(ioPackage, baseName, tool.interfaceId()));
+ "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")), writeUtf8(sourceRoot.resolve(Paths.get("biz", tool.group().toLowerCase(Locale.ROOT), "converter", baseName + "Converter.java")),
groupedMciConverterContent(bizPackage, baseName, ioPackage)); groupedMciConverterContent(bizPackage, baseName, ioPackage));
} else { } else {
@@ -293,27 +286,23 @@ public class ToolScaffolder {
clientVariable = Character.toLowerCase(baseName.charAt(0)) + baseName.substring(1) + "Client"; clientVariable = Character.toLowerCase(baseName.charAt(0)) + baseName.substring(1) + "Client";
} }
String converterVariable = Character.toLowerCase(baseName.charAt(0)) + baseName.substring(1) + "Converter"; String converterVariable = Character.toLowerCase(baseName.charAt(0)) + baseName.substring(1) + "Converter";
String integrationSysCode = tool.clientSystemCode().toLowerCase(Locale.ROOT); String integrationPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." + tool.clientSystemCode().toLowerCase(Locale.ROOT)
String sysCodePath = integrationSysCode.length() == 4 ? integrationSysCode.substring(0, 3) + "." + integrationSysCode.substring(3) : integrationSysCode; : ".infra.itrf.http." + toPackageSegment(tool.httpApiName()));
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") 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(".dto.").append(baseName).append("Response;\n")
.append("import ").append(bizPackage).append(".converter.").append(baseName).append("Converter;\n") .append("import ").append(bizPackage).append(".converter.").append(baseName).append("Converter;\n")
.append("import ").append(integrationPackage).append(".").append(clientClassName).append(";\n") .append("import ").append(integrationPackage).append(".").append(clientClassName).append(";\n")
.append("import ").append(integrationPackage).append(".io.").append(baseName) .append("import ").append(integrationPackage).append(".io.").append(mci ? tool.interfaceId() + "_I;\n" : baseName + "HttpRequest;\n")
.append(mci ? "_I;\n" : "HttpRequest;\n") .append("import ").append(integrationPackage).append(".io.").append(mci ? tool.interfaceId() + "_O;\n" : baseName + "HttpResponse;\n");
.append("import ").append(integrationPackage).append(".io.").append(baseName)
.append(mci ? "_O;\n" : "HttpResponse;\n");
if (!fields.toString().contains(" " + clientVariable + ";")) { if (!fields.toString().contains(" " + clientVariable + ";")) {
fields.append(" private final ").append(clientClassName).append(" ").append(clientVariable).append(";\n"); fields.append(" private final ").append(clientClassName).append(" ").append(clientVariable).append(";\n");
} }
fields.append(" private final ").append(baseName).append("Converter ").append(converterVariable).append(";\n"); fields.append(" private final ").append(baseName).append("Converter ").append(converterVariable).append(";\n");
methods.append(" @Override\n public ").append(baseName).append("Response ").append(tool.methodName()) methods.append(" @Override\n public ").append(baseName).append("Response ").append(tool.methodName())
.append("(").append(baseName).append("Request req) {\n") .append("(").append(baseName).append("Request req) {\n")
.append(" ").append(baseName).append(mci ? "_I" : "HttpRequest").append(" request = ").append(converterVariable).append(".toRequest(req);\n") .append(" ").append(mci ? tool.interfaceId() + "_I" : baseName + "HttpRequest").append(" request = ").append(converterVariable).append(".toRequest(req);\n")
.append(" ").append(baseName).append(mci ? "_O" : "HttpResponse").append(" response = ").append(clientVariable) .append(" ").append(mci ? tool.interfaceId() + "_O" : baseName + "HttpResponse").append(" response = ").append(clientVariable)
.append(mci ? ".callTo(\"" + tool.interfaceId() + "\", null, request, " + baseName + "_O.class).getBody();\n" : ".call(request, " + baseName + "HttpResponse.class);\n") .append(mci ? ".callTo(\"" + tool.interfaceId() + "\", null, request, " + tool.interfaceId() + "_O.class).getBody();\n" : ".call(request, " + baseName + "HttpResponse.class);\n")
.append(" ").append(baseName).append("Response toolResponse = ").append(converterVariable).append(".toResponse(response);\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(" if (toolResponse == null) toolResponse = new ").append(baseName).append("Response();\n")
.append(" toolResponse.setResultCode(\"SUCCESS\");\n") .append(" toolResponse.setResultCode(\"SUCCESS\");\n")
@@ -375,10 +364,8 @@ public class ToolScaffolder {
throw new IllegalArgumentException("Tool method or MCP Tool name already exists: " + methodName); throw new IllegalArgumentException("Tool method or MCP Tool name already exists: " + methodName);
} }
boolean mci = "MCI".equalsIgnoreCase(tool.routingType()); boolean mci = "MCI".equalsIgnoreCase(tool.routingType());
String integrationSysCode = tool.clientSystemCode().toLowerCase(Locale.ROOT); String integrationPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." + tool.clientSystemCode().toLowerCase(Locale.ROOT)
String sysCodePath = integrationSysCode.length() == 4 ? integrationSysCode.substring(0, 3) + "." + integrationSysCode.substring(3) : integrationSysCode; : ".infra.itrf.http." + toPackageSegment(tool.httpApiName()));
String integrationPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." + sysCodePath
: ".infra.itrf.http." + toPackageSegment(tool.httpApiName()));
String requestType = baseName + "Request"; String requestType = baseName + "Request";
String responseType = baseName + "Response"; String responseType = baseName + "Response";
String requestIo = baseName + (mci ? "_I" : "HttpRequest"); String requestIo = baseName + (mci ? "_I" : "HttpRequest");
@@ -662,9 +649,9 @@ public class ToolScaffolder {
Path mciClientDir = null; Path mciClientDir = null;
if (isMci && clientSystemCode != null && clientSystemCode.length() == 4) { if (isMci && clientSystemCode != null && clientSystemCode.length() == 4) {
String clientPrefix = clientSystemCode.length() == 4 ? clientSystemCode.substring(0,3).toLowerCase() + "/" + clientSystemCode.substring(3).toLowerCase() : clientSystemCode.toLowerCase(); String clientPrefix = clientSystemCode.toLowerCase();
clientPrefixCap = toPascalCase(clientSystemCode); clientPrefixCap = toPascalCase(clientSystemCode);
mciGroupPath = "infra/itrf/mci/" + clientPrefix; mciGroupPath = "infra/itrf/mci/" + clientPrefix.substring(0, 3) + "/" + clientPrefix.substring(3);
mciClientDir = rootDir.resolve(Paths.get(moduleName, BASE_PACKAGE_PATH, mciGroupPath)); mciClientDir = rootDir.resolve(Paths.get(moduleName, BASE_PACKAGE_PATH, mciGroupPath));
} }