refactor: rename controller packages to presentation to comply with standard guidelines
This commit is contained in:
72
RefactorPackage.java
Normal file
72
RefactorPackage.java
Normal file
@@ -0,0 +1,72 @@
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
public class RefactorPackage {
|
||||
|
||||
static final String ROOT_DIR = ".";
|
||||
|
||||
static final String[] DIR_RENAMES = {
|
||||
"./axhub-gateway/src/main/java/io/shinhanlife/axhub/biz/mcp/gateway/controller",
|
||||
"./axhub-gateway/src/main/java/io/shinhanlife/axhub/biz/mcp/gateway/presentation",
|
||||
"./axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/controller",
|
||||
"./axhub-tool-core/src/main/java/io/shinhanlife/axhub/biz/mcp/tool/presentation"
|
||||
};
|
||||
|
||||
static final String[][] STRING_REPLACEMENTS = {
|
||||
{"io.shinhanlife.axhub.biz.mcp.gateway.controller", "io.shinhanlife.axhub.biz.mcp.gateway.presentation"},
|
||||
{"io.shinhanlife.axhub.biz.mcp.tool.controller", "io.shinhanlife.axhub.biz.mcp.tool.presentation"}
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// 1. Rename Directories
|
||||
for (int i = 0; i < DIR_RENAMES.length; i += 2) {
|
||||
File srcDir = new File(DIR_RENAMES[i]);
|
||||
File destDir = new File(DIR_RENAMES[i+1]);
|
||||
if (srcDir.exists() && srcDir.isDirectory()) {
|
||||
boolean success = srcDir.renameTo(destDir);
|
||||
System.out.println("Renamed " + srcDir.getPath() + " to " + destDir.getPath() + " : " + success);
|
||||
} else {
|
||||
System.out.println("Source dir not found or not a directory: " + srcDir.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Replace string contents in all .java files
|
||||
Files.walkFileTree(Paths.get(ROOT_DIR), new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
|
||||
String name = dir.getFileName().toString();
|
||||
if (name.equals(".git") || name.equals("build") || name.equals(".gradle") || name.equals("out") || name.equals("bin") || name.equals("scratch")) {
|
||||
return FileVisitResult.SKIP_SUBTREE;
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
if (file.toString().endsWith(".java") && !file.getFileName().toString().equals("RefactorPackage.java") && !file.getFileName().toString().equals("AddJavadoc.java")) {
|
||||
processJavaFile(file);
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
System.out.println("Done.");
|
||||
}
|
||||
|
||||
private static void processJavaFile(Path file) throws IOException {
|
||||
String content = new String(Files.readAllBytes(file), "UTF-8");
|
||||
boolean modified = false;
|
||||
|
||||
for (String[] rep : STRING_REPLACEMENTS) {
|
||||
if (content.contains(rep[0])) {
|
||||
content = content.replace(rep[0], rep[1]);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
Files.write(file, content.getBytes("UTF-8"));
|
||||
System.out.println("Updated imports/package in: " + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import org.springframework.util.StopWatch;
|
||||
public class GatewayLoggingAspect {
|
||||
|
||||
// gateway의 controller 패키지 하위의 모든 클래스/메서드 실행 시 작동
|
||||
@Around("execution(* io.shinhanlife.axhub.biz.mcp.gateway.controller..*(..))")
|
||||
@Around("execution(* io.shinhanlife.axhub.biz.mcp.gateway.presentation..*(..))")
|
||||
public Object logGatewayExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
String targetMethod = joinPoint.getSignature().toShortString();
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.shinhanlife.axhub.biz.mcp.gateway.controller;
|
||||
package io.shinhanlife.axhub.biz.mcp.gateway.presentation;
|
||||
|
||||
import io.shinhanlife.axhub.biz.mcp.gateway.service.KillSwitchService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @package io.shinhanlife.axhub.biz.mcp.gateway.controller
|
||||
* @package io.shinhanlife.axhub.biz.mcp.gateway.presentation
|
||||
* @className KillSwitchController
|
||||
* @description AX HUB 시스템 처리 클래스
|
||||
* @author 김형식
|
||||
@@ -1,11 +1,11 @@
|
||||
package io.shinhanlife.axhub.biz.mcp.gateway.controller;
|
||||
package io.shinhanlife.axhub.biz.mcp.gateway.presentation;
|
||||
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @package io.shinhanlife.axhub.biz.mcp.gateway.controller
|
||||
* @package io.shinhanlife.axhub.biz.mcp.gateway.presentation
|
||||
* @className MciMockController
|
||||
* @description AX HUB 시스템 처리 클래스
|
||||
* @author 김형식
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.shinhanlife.axhub.biz.mcp.gateway.controller;
|
||||
package io.shinhanlife.axhub.biz.mcp.gateway.presentation;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.shinhanlife.axhub.biz.mcp.adapter.dto.JsonRpcRequest;
|
||||
@@ -20,7 +20,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
/**
|
||||
* @package io.shinhanlife.axhub.biz.mcp.gateway.controller
|
||||
* @package io.shinhanlife.axhub.biz.mcp.gateway.presentation
|
||||
* @className McpRouterController
|
||||
* @description AX HUB 시스템 처리 클래스
|
||||
* @author 김형식
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.shinhanlife.axhub.biz.mcp.tool.controller;
|
||||
package io.shinhanlife.axhub.biz.mcp.tool.presentation;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -29,7 +29,7 @@ import io.shinhanlife.axhub.biz.mcp.tool.util.JsonSchemaGenerator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @package io.shinhanlife.axhub.biz.mcp.tool.controller
|
||||
* @package io.shinhanlife.axhub.biz.mcp.tool.presentation
|
||||
* @className BusinessToolController
|
||||
* @description AX HUB 시스템 처리 클래스
|
||||
* @author 김형식
|
||||
Reference in New Issue
Block a user