添加文件服务aop,优化代码生成工具

This commit is contained in:
2026-05-19 09:37:51 +08:00
parent a3e4089e2c
commit 0de0d3a134
3 changed files with 139 additions and 31 deletions

View File

@@ -333,18 +333,18 @@ public class GenServiceImpl implements GenService, BaseParams {
String subModuleName = datasource.getSubModuleName();
String tableName = table.getTableName();
// 获取uri
int indexOf = tableName.indexOf("_");
int indexOf = tableName.indexOf(CP_UNDERLINE);
String uri;
if (indexOf > CP_NEGATIVE1) {
uri = tableName.substring(CP_NUM0, indexOf) + CP_SLASH + tableName.substring(indexOf + CP_NUM1).replaceAll("_", CP_LINE);
uri = tableName.substring(CP_NUM0, indexOf) + CP_SLASH + tableName.substring(indexOf + CP_NUM1).replace(CP_UNDERLINE, CP_LINE);
} else {
uri = tableName;
}
// 获取按钮权限前缀
String btnPermPrefix = uri.replaceAll(CP_SLASH, CP_COLON);
String btnPermPrefix = uri.replace(CP_SLASH, CP_COLON);
// 获取dbid
List<Long> dbIdList = getDbIdList(CP_NUM20);
// 获取dbId
List<Long> dbIdList = getDbIdList();
// 获取父级菜单ID和树路径
String parentMenuId = table.getParentMenuId();
String treePath;
@@ -356,7 +356,7 @@ public class GenServiceImpl implements GenService, BaseParams {
parentId = "parentId";
treePath = "treePath";
}
String component = subModuleName + CP_SLASH + tableName.replace("_", "-") + CP_SLASH + "index";
String component = subModuleName + CP_SLASH + tableName.replace(CP_UNDERLINE, CP_LINE) + CP_SLASH + "index";
// 根据配置文件生成模板
Map<String, GenProperties.TemplateConfig> templateConfigs = genProperties.getTemplateConfigs();
@@ -429,7 +429,7 @@ public class GenServiceImpl implements GenService, BaseParams {
map.put("subPackageName", value.getSubPackageName());
map.put("uri", uri);
map.put("btnPermPrefix", btnPermPrefix);
map.put("apiPath", tableName.replace("_", "-") + "-api");
map.put("apiPath", tableName.replace(CP_UNDERLINE, CP_LINE) + "-api");
map.put("dbIds", dbIdList);
map.put("parentId", parentId);
@@ -455,10 +455,10 @@ public class GenServiceImpl implements GenService, BaseParams {
/**
* 获取数据库 ID 列表
*
* @param count 获取个数
* @return 数据库 ID 列表
*/
private List<Long> getDbIdList(int count) {
private List<Long> getDbIdList() {
int count = CP_NUM20;
InetAddress localHost;
try {
localHost = InetAddress.getLocalHost();
@@ -487,7 +487,7 @@ public class GenServiceImpl implements GenService, BaseParams {
return switch (type) {
case "Entity", "Sql" -> entityName + extension;
case "TS_API" -> tableName.replace("_", "-") + "-api" + extension;
case "TS_API" -> tableName.replace(CP_UNDERLINE, CP_LINE) + "-api" + extension;
case "VUE_VIEW" -> "index" + extension;
default -> entityName + type + extension;
};
@@ -511,7 +511,7 @@ public class GenServiceImpl implements GenService, BaseParams {
case ".java" -> {
joiner.add(genProperties.getBackendAppName());
joiner.add(moduleName);
joiner.add(moduleName + "-" + projectModule);
joiner.add(moduleName + CP_LINE + projectModule);
joiner.add("src");
joiner.add("main");
joiner.add("java");
@@ -529,7 +529,7 @@ public class GenServiceImpl implements GenService, BaseParams {
joiner.add("src");
joiner.add(subPackageName.replace(CP_DOT, CP_SLASH));
joiner.add(subModuleName);
joiner.add(tableName.replace("_", "-"));
joiner.add(tableName.replace(CP_UNDERLINE, CP_LINE));
}
case ".sql" -> joiner.add("sql");
default -> joiner.add(CP_EMPTY);