feat: Scaffold UI 및 로직 9자리 Target System Code 지원 업데이트
Some checks failed
Deploy to OCIWP / deploy (push) Failing after 31s
Some checks failed
Deploy to OCIWP / deploy (push) Failing after 31s
- 폐쇄망 환경을 위한 Bootstrap 등 정적 자원 로컬화 (cdn -> vendor) 적용 - Target System Code를 9자리(예: ONBTI2370)까지 입력받을 수 있도록 수정 - 9자리 입력 시, 2~5번째 문자를 추출하여 패키지 경로 및 Client 클래스 명명에 사용하도록 ToolScaffolder 로직 변경 - IO DTO 이름 생성 규칙(interfaceId -> ioPrefix) 수정
This commit is contained in:
@@ -162,12 +162,22 @@ public class ToolScaffolder {
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatClientSystemCode(String code, String delimiter) {
|
||||
if (code == null) return "";
|
||||
if (code.length() == 9) {
|
||||
return code.substring(1, 4).toLowerCase(Locale.ROOT) + delimiter + code.substring(4, 5).toLowerCase(Locale.ROOT);
|
||||
} else if (code.length() == 4) {
|
||||
return code.substring(0, 3).toLowerCase(Locale.ROOT) + delimiter + code.substring(3).toLowerCase(Locale.ROOT);
|
||||
}
|
||||
return code.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
private static void writeGroupedToolFiles(Path moduleRoot, Path sourceRoot, Path dtoDir, Path definitionDir,
|
||||
Path mockDir, String bizPackage, ToolMethodDefinition tool,
|
||||
String moduleName, StringBuilder log) throws IOException {
|
||||
String baseName = toPascalCase(tool.baseName());
|
||||
boolean mci = "MCI".equalsIgnoreCase(tool.routingType());
|
||||
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 code = mci ? formatClientSystemCode(tool.clientSystemCode(), "/") : toPackageSegment(tool.httpApiName());
|
||||
String ioPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." : ".infra.itrf.http.") + code.replace("/", ".");
|
||||
Path clientDir = sourceRoot.resolve(Paths.get("infra", "itrf", mci ? "mci" : "http", code));
|
||||
Path ioDir = clientDir.resolve("io");
|
||||
@@ -179,22 +189,24 @@ public class ToolScaffolder {
|
||||
writeStructuredFieldTypes(dtoDir, bizPackage + ".dto", baseName + "Request", tool.inputFields());
|
||||
writeStructuredFieldTypes(dtoDir, bizPackage + ".dto", baseName + "Response", tool.outputFields());
|
||||
if (mci) {
|
||||
writeUtf8(ioDir.resolve(tool.interfaceId() + "_I.java"),
|
||||
mciIoContent("infra.itrf.mci." + code.replace("/", "."), tool.interfaceId() + "_I", tool.inputFields(), "", ""));
|
||||
writeUtf8(ioDir.resolve(tool.interfaceId() + "_O.java"),
|
||||
mciIoContent("infra.itrf.mci." + code.replace("/", "."), tool.interfaceId() + "_O", tool.outputFields(), "", ""));
|
||||
writeStructuredFieldTypes(ioDir, ioPackage + ".io", tool.interfaceId() + "_I", tool.inputFields());
|
||||
writeStructuredFieldTypes(ioDir, ioPackage + ".io", tool.interfaceId() + "_O", tool.outputFields());
|
||||
String ioPrefix = (tool.clientSystemCode() != null && !tool.clientSystemCode().isBlank()) ? tool.clientSystemCode().toUpperCase() : tool.interfaceId();
|
||||
writeUtf8(ioDir.resolve(ioPrefix + "_I.java"),
|
||||
mciIoContent("infra.itrf.mci." + code.replace("/", "."), ioPrefix + "_I", tool.inputFields(), "", ""));
|
||||
writeUtf8(ioDir.resolve(ioPrefix + "_O.java"),
|
||||
mciIoContent("infra.itrf.mci." + code.replace("/", "."), ioPrefix + "_O", tool.outputFields(), "", ""));
|
||||
writeStructuredFieldTypes(ioDir, ioPackage + ".io", ioPrefix + "_I", tool.inputFields());
|
||||
writeStructuredFieldTypes(ioDir, ioPackage + ".io", ioPrefix + "_O", tool.outputFields());
|
||||
String sysCode = tool.clientSystemCode();
|
||||
if (sysCode != null && sysCode.length() == 4) {
|
||||
String clientCap = toPascalCase(sysCode);
|
||||
if (sysCode != null && (sysCode.length() == 4 || sysCode.length() == 9)) {
|
||||
String clientPrefix = sysCode.length() == 9 ? sysCode.substring(1, 5) : sysCode;
|
||||
String clientCap = toPascalCase(clientPrefix);
|
||||
writeUtf8(clientDir.resolve("Mci" + clientCap + "Client.java"),
|
||||
"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");
|
||||
} else {
|
||||
writeUtf8(clientDir.resolve(baseName + "Client.java"), groupedMciClientContent(ioPackage, baseName, tool.interfaceId()));
|
||||
}
|
||||
writeUtf8(sourceRoot.resolve(Paths.get("biz", tool.group().toLowerCase(Locale.ROOT), "converter", baseName + "Converter.java")),
|
||||
groupedMciConverterContent(bizPackage, baseName, ioPackage, tool.interfaceId()));
|
||||
groupedMciConverterContent(bizPackage, baseName, ioPackage, ioPrefix));
|
||||
} else {
|
||||
writeUtf8(ioDir.resolve(baseName + "HttpRequest.java"),
|
||||
dtoContent(ioPackage + ".io", baseName + "HttpRequest", tool.inputFields(), "", "", true));
|
||||
@@ -277,32 +289,35 @@ public class ToolScaffolder {
|
||||
String clientClassName;
|
||||
String clientVariable;
|
||||
boolean mci = "MCI".equalsIgnoreCase(tool.routingType());
|
||||
String ioPrefix = (tool.clientSystemCode() != null && !tool.clientSystemCode().isBlank()) ? tool.clientSystemCode().toUpperCase() : tool.interfaceId();
|
||||
if (mci) {
|
||||
String sysCode = tool.clientSystemCode().toLowerCase(Locale.ROOT);
|
||||
clientClassName = "Mci" + sysCode.substring(0, 1).toUpperCase(Locale.ROOT) + sysCode.substring(1) + "Client";
|
||||
clientVariable = "mci" + sysCode.substring(0, 1).toUpperCase(Locale.ROOT) + sysCode.substring(1) + "Client";
|
||||
String sysCode = tool.clientSystemCode();
|
||||
String clientPrefix = (sysCode != null && sysCode.length() == 9) ? sysCode.substring(1, 5) : sysCode;
|
||||
clientPrefix = clientPrefix.toLowerCase(Locale.ROOT);
|
||||
clientClassName = "Mci" + clientPrefix.substring(0, 1).toUpperCase(Locale.ROOT) + clientPrefix.substring(1) + "Client";
|
||||
clientVariable = "mci" + clientPrefix.substring(0, 1).toUpperCase(Locale.ROOT) + clientPrefix.substring(1) + "Client";
|
||||
} else {
|
||||
clientClassName = baseName + "Client";
|
||||
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().length() == 4 ? tool.clientSystemCode().substring(0,3).toLowerCase(Locale.ROOT) + "." + tool.clientSystemCode().substring(3).toLowerCase(Locale.ROOT) : tool.clientSystemCode().toLowerCase(Locale.ROOT))
|
||||
String integrationPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." + formatClientSystemCode(tool.clientSystemCode(), ".")
|
||||
: ".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")
|
||||
.append("import ").append(integrationPackage).append(".").append(clientClassName).append(";\n")
|
||||
.append("import ").append(integrationPackage).append(".io.").append(mci ? tool.interfaceId() + "_I;\n" : baseName + "HttpRequest;\n")
|
||||
.append("import ").append(integrationPackage).append(".io.").append(mci ? tool.interfaceId() + "_O;\n" : baseName + "HttpResponse;\n");
|
||||
.append("import ").append(integrationPackage).append(".io.").append(mci ? ioPrefix + "_I;\n" : baseName + "HttpRequest;\n")
|
||||
.append("import ").append(integrationPackage).append(".io.").append(mci ? ioPrefix + "_O;\n" : baseName + "HttpResponse;\n");
|
||||
if (!fields.toString().contains(" " + clientVariable + ";")) {
|
||||
fields.append(" private final ").append(clientClassName).append(" ").append(clientVariable).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())
|
||||
.append("(").append(baseName).append("Request req) {\n")
|
||||
.append(" ").append(mci ? tool.interfaceId() + "_I" : baseName + "HttpRequest").append(" request = ").append(converterVariable).append(".toRequest(req);\n")
|
||||
.append(" ").append(mci ? tool.interfaceId() + "_O" : baseName + "HttpResponse").append(" response = ").append(clientVariable)
|
||||
.append(mci ? ".callTo(\"" + tool.interfaceId() + "\", null, request, " + tool.interfaceId() + "_O.class).getBody();\n" : ".call(request, " + baseName + "HttpResponse.class);\n")
|
||||
.append(" ").append(mci ? ioPrefix + "_I" : baseName + "HttpRequest").append(" request = ").append(converterVariable).append(".toRequest(req);\n")
|
||||
.append(" ").append(mci ? ioPrefix + "_O" : baseName + "HttpResponse").append(" response = ").append(clientVariable)
|
||||
.append(mci ? ".callTo(\"" + tool.interfaceId() + "\", null, request, " + ioPrefix + "_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")
|
||||
@@ -364,12 +379,13 @@ 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().length() == 4 ? tool.clientSystemCode().substring(0,3).toLowerCase(Locale.ROOT) + "." + tool.clientSystemCode().substring(3).toLowerCase(Locale.ROOT) : tool.clientSystemCode().toLowerCase(Locale.ROOT))
|
||||
String integrationPackage = BASE_PACKAGE + (mci ? ".infra.itrf.mci." + formatClientSystemCode(tool.clientSystemCode(), ".")
|
||||
: ".infra.itrf.http." + toPackageSegment(tool.httpApiName()));
|
||||
String requestType = baseName + "Request";
|
||||
String responseType = baseName + "Response";
|
||||
String requestIo = mci ? tool.interfaceId() + "_I" : baseName + "HttpRequest";
|
||||
String responseIo = mci ? tool.interfaceId() + "_O" : baseName + "HttpResponse";
|
||||
String ioPrefix = (tool.clientSystemCode() != null && !tool.clientSystemCode().isBlank()) ? tool.clientSystemCode().toUpperCase() : tool.interfaceId();
|
||||
String requestIo = mci ? ioPrefix + "_I" : baseName + "HttpRequest";
|
||||
String responseIo = mci ? ioPrefix + "_O" : baseName + "HttpResponse";
|
||||
|
||||
useCase = addImport(useCase, "import " + bizPackage + ".dto." + requestType + ";") ;
|
||||
useCase = addImport(useCase, "import " + bizPackage + ".dto." + responseType + ";") ;
|
||||
@@ -644,13 +660,14 @@ public class ToolScaffolder {
|
||||
if (!isMci && !isHttp) {
|
||||
throw new IllegalArgumentException("Unsupported routing type: " + routingType + ". Only MCI and HTTP are supported.");
|
||||
}
|
||||
String ioPrefix = (clientSystemCode != null && !clientSystemCode.isBlank()) ? clientSystemCode.toUpperCase() : interfaceId;
|
||||
String mciGroupPath = "infra/itrf/mci/" + group.toLowerCase();
|
||||
String clientPrefixCap = "";
|
||||
Path mciClientDir = null;
|
||||
|
||||
if (isMci && clientSystemCode != null && clientSystemCode.length() == 4) {
|
||||
String clientPrefix = clientSystemCode.toLowerCase();
|
||||
clientPrefixCap = toPascalCase(clientSystemCode);
|
||||
if (isMci && clientSystemCode != null && (clientSystemCode.length() == 4 || clientSystemCode.length() == 9)) {
|
||||
String clientPrefix = clientSystemCode.length() == 9 ? clientSystemCode.substring(1, 5).toLowerCase() : clientSystemCode.toLowerCase();
|
||||
clientPrefixCap = toPascalCase(clientPrefix);
|
||||
mciGroupPath = "infra/itrf/mci/" + clientPrefix.substring(0, 3) + "/" + clientPrefix.substring(3);
|
||||
mciClientDir = rootDir.resolve(Paths.get(moduleName, BASE_PACKAGE_PATH, mciGroupPath));
|
||||
}
|
||||
@@ -914,7 +931,7 @@ public class ToolScaffolder {
|
||||
bizPackage, baseName,
|
||||
bizPackage, baseName,
|
||||
bizPackage, baseName,
|
||||
BASE_PACKAGE, mciGroupPath.replace("/", "."), interfaceId,
|
||||
BASE_PACKAGE, mciGroupPath.replace("/", "."), ioPrefix,
|
||||
(clientPrefixCap.isEmpty() ? "" : "import " + BASE_PACKAGE + "." + mciGroupPath.replace("/", ".") + ".Mci" + clientPrefixCap + "Client;\n"),
|
||||
bizPackage,
|
||||
baseName,
|
||||
@@ -928,7 +945,7 @@ public class ToolScaffolder {
|
||||
baseName,
|
||||
baseName,
|
||||
toolName,
|
||||
interfaceId,
|
||||
ioPrefix,
|
||||
interfaceId,
|
||||
baseName,
|
||||
baseName,
|
||||
@@ -937,10 +954,10 @@ public class ToolScaffolder {
|
||||
);
|
||||
String mciIoPackage = BASE_PACKAGE + "." + mciGroupPath.replace("/", ".");
|
||||
serviceImplContent = serviceImplContent
|
||||
.replace("import " + mciIoPackage + ".io." + interfaceId + "_I;",
|
||||
"import " + mciIoPackage + ".io." + interfaceId + "_I;\nimport " + mciIoPackage + ".io." + interfaceId + "_O;")
|
||||
.replace("Transfer<Object> resTransfer", "Transfer<" + interfaceId + "_O> resTransfer")
|
||||
.replace("Object.class", interfaceId + "_O.class")
|
||||
.replace("import " + mciIoPackage + ".io." + ioPrefix + "_I;",
|
||||
"import " + mciIoPackage + ".io." + ioPrefix + "_I;\nimport " + mciIoPackage + ".io." + ioPrefix + "_O;")
|
||||
.replace("Transfer<Object> resTransfer", "Transfer<" + ioPrefix + "_O> resTransfer")
|
||||
.replace("Object.class", ioPrefix + "_O.class")
|
||||
.replace("response.setResultCode(\"SUCCESS\");",
|
||||
"if (resTransfer.getBody() != null) {\n response = converter.toResponse(resTransfer.getBody());\n }\n response.setResultCode(\"SUCCESS\");");
|
||||
} else {
|
||||
@@ -1016,6 +1033,7 @@ public class ToolScaffolder {
|
||||
writeUtf8(usecaseImplDir.resolve(baseName + "UseCaseImpl.java"), serviceImplContent);
|
||||
|
||||
if (isMci) {
|
||||
|
||||
String mciReqContent = """
|
||||
package %s.%s.io;
|
||||
|
||||
@@ -1037,6 +1055,7 @@ public class ToolScaffolder {
|
||||
*/
|
||||
@Data
|
||||
public class %s_I {
|
||||
// TODO: Add request fields here
|
||||
/**
|
||||
* EAI 시스템이 요구하는 수신자 번호 파라미터명
|
||||
*/
|
||||
@@ -1047,10 +1066,10 @@ public class ToolScaffolder {
|
||||
*/
|
||||
private String content;
|
||||
}
|
||||
""".formatted(BASE_PACKAGE, mciGroupPath.replace("/", "."), BASE_PACKAGE, mciGroupPath.replace("/", "."), interfaceId, author, createDate, createDate, author, interfaceId);
|
||||
mciReqContent = mciIoContent(mciGroupPath.replace("/", "."), interfaceId + "_I", inputFields, author, createDate);
|
||||
writeUtf8(mciIoDir.resolve(interfaceId + "_I.java"), mciReqContent);
|
||||
writeStructuredFieldTypes(mciIoDir, BASE_PACKAGE + "." + mciGroupPath.replace("/", ".") + ".io", interfaceId + "_I", inputFields);
|
||||
""".formatted(BASE_PACKAGE, mciGroupPath.replace("/", "."), BASE_PACKAGE, mciGroupPath.replace("/", "."), ioPrefix, author, createDate, createDate, author, ioPrefix);
|
||||
mciReqContent = mciIoContent(mciGroupPath.replace("/", "."), ioPrefix + "_I", inputFields, author, createDate);
|
||||
writeUtf8(mciIoDir.resolve(ioPrefix + "_I.java"), mciReqContent);
|
||||
writeStructuredFieldTypes(mciIoDir, BASE_PACKAGE + "." + mciGroupPath.replace("/", ".") + ".io", ioPrefix + "_I", inputFields);
|
||||
|
||||
String mciResContent = """
|
||||
package %s.%s.io;
|
||||
@@ -1075,10 +1094,10 @@ public class ToolScaffolder {
|
||||
public class %s_O {
|
||||
// TODO: Add response fields here
|
||||
}
|
||||
""".formatted(BASE_PACKAGE, mciGroupPath.replace("/", "."), BASE_PACKAGE, mciGroupPath.replace("/", "."), interfaceId, author, createDate, createDate, author, interfaceId);
|
||||
mciResContent = mciIoContent(mciGroupPath.replace("/", "."), interfaceId + "_O", outputFields, author, createDate);
|
||||
writeUtf8(mciIoDir.resolve(interfaceId + "_O.java"), mciResContent);
|
||||
writeStructuredFieldTypes(mciIoDir, BASE_PACKAGE + "." + mciGroupPath.replace("/", ".") + ".io", interfaceId + "_O", outputFields);
|
||||
""".formatted(BASE_PACKAGE, mciGroupPath.replace("/", "."), BASE_PACKAGE, mciGroupPath.replace("/", "."), ioPrefix, author, createDate, createDate, author, ioPrefix);
|
||||
mciResContent = mciIoContent(mciGroupPath.replace("/", "."), ioPrefix + "_O", outputFields, author, createDate);
|
||||
writeUtf8(mciIoDir.resolve(ioPrefix + "_O.java"), mciResContent);
|
||||
writeStructuredFieldTypes(mciIoDir, BASE_PACKAGE + "." + mciGroupPath.replace("/", ".") + ".io", ioPrefix + "_O", outputFields);
|
||||
|
||||
String converterContent = """
|
||||
package %s.converter;
|
||||
@@ -1122,14 +1141,14 @@ public class ToolScaffolder {
|
||||
bizPackage,
|
||||
bizPackage, baseName,
|
||||
bizPackage, baseName,
|
||||
BASE_PACKAGE, mciGroupPath.replace("/", "."), interfaceId,
|
||||
BASE_PACKAGE, mciGroupPath.replace("/", "."), interfaceId,
|
||||
BASE_PACKAGE, mciGroupPath.replace("/", "."), ioPrefix,
|
||||
BASE_PACKAGE, mciGroupPath.replace("/", "."), ioPrefix,
|
||||
bizPackage, baseName, author, createDate, createDate, author,
|
||||
baseName, interfaceId, baseName,
|
||||
baseName, interfaceId,
|
||||
baseName, interfaceId
|
||||
baseName, ioPrefix, baseName,
|
||||
baseName, ioPrefix,
|
||||
baseName, ioPrefix
|
||||
);
|
||||
converterContent = mciConverterContent(bizPackage, baseName, mciGroupPath.replace("/", "."), interfaceId);
|
||||
converterContent = mciConverterContent(bizPackage, baseName, mciGroupPath.replace("/", "."), ioPrefix);
|
||||
writeUtf8(converterDir.resolve(baseName + "Converter.java"), converterContent);
|
||||
|
||||
log.append("\n=========================================\n");
|
||||
|
||||
Reference in New Issue
Block a user