|
|
|
@ -60,6 +60,10 @@ public class SpringBootCallable implements Callable {
|
|
|
|
|
if (!src.exists()) {
|
|
|
|
|
src.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
File moduleDir = new File(src,"module");
|
|
|
|
|
if (!moduleDir.exists()) {
|
|
|
|
|
moduleDir.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 生成资源目录
|
|
|
|
|
stringBuffer = new StringBuffer(projectDir.getAbsolutePath() + File.separator + "src" + File.separator + "main");
|
|
|
|
@ -102,14 +106,13 @@ public class SpringBootCallable implements Callable {
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Module module = new Module();
|
|
|
|
|
File api = new File(src.getAbsolutePath(), "api");
|
|
|
|
|
File api = new File(moduleDir.getAbsolutePath(), "api");
|
|
|
|
|
api.mkdirs();
|
|
|
|
|
module.setModuleName("api");
|
|
|
|
|
module.setProjectAuthor(project.getProjectAuthor());
|
|
|
|
|
module.setProjectBasePackage(project.getProjectBasePackage());
|
|
|
|
|
module.setProjectName(project.getProjectName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("生成模块:Entity");
|
|
|
|
|
generateEntity(new File(api.getAbsolutePath(), "ent"), module, dataBase, option);
|
|
|
|
|
System.out.println("生成模块:Enums");
|
|
|
|
@ -128,7 +131,7 @@ public class SpringBootCallable implements Callable {
|
|
|
|
|
module.setProjectBasePackage(project.getProjectBasePackage());
|
|
|
|
|
module.setProjectName(project.getProjectName());
|
|
|
|
|
|
|
|
|
|
File modulePath = new File(src.getAbsolutePath(), module.getModuleName());
|
|
|
|
|
File modulePath = new File(moduleDir.getAbsolutePath(), module.getModuleName());
|
|
|
|
|
modulePath.mkdirs();
|
|
|
|
|
|
|
|
|
|
System.out.println("生成模块:Entity");
|
|
|
|
@ -267,7 +270,7 @@ public class SpringBootCallable implements Callable {
|
|
|
|
|
|
|
|
|
|
File file = new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + ".java");
|
|
|
|
|
|
|
|
|
|
freeMarkerManager.outputTemp(file, option + "/java/ent/entity.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(file, option + "/java/module/ent/entity.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -301,7 +304,7 @@ public class SpringBootCallable implements Callable {
|
|
|
|
|
if ("Enum".equals(field.getFieldType().javaType())) {
|
|
|
|
|
ctx.put("Type", field.getCName());
|
|
|
|
|
ctx.put("FieldComment", field.getFieldComment());
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), field.getCName() + ".java"), option + "/java/enums/Type.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), field.getCName() + ".java"), option + "/java/module/enums/Type.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -331,12 +334,12 @@ public class SpringBootCallable implements Callable {
|
|
|
|
|
|
|
|
|
|
for (Table table : md.getTables()) {
|
|
|
|
|
ctx.put("table", table);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".java"), option + "/java/mpr/mapperJava.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".java"), option + "/java/module/mpr/mapperJava.ftl", ctx);
|
|
|
|
|
|
|
|
|
|
if (md.isHasSysFields()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".xml"), option + "/java/mpr/mapper.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".xml"), option + "/java/module/mpr/mapper.ftl", ctx);
|
|
|
|
|
} else {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".xml"), option + "/java/mpr/mapper_nosys.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Mapper" + ".xml"), option + "/java/module/mpr/mapper_nosys.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -357,14 +360,14 @@ public class SpringBootCallable implements Callable {
|
|
|
|
|
ctx.put("date", new Date());
|
|
|
|
|
|
|
|
|
|
if (md.getModuleName().equals("api")) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiManager" + ".java"), option + "/java/mgr/ApiManager.java", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiManagerImpl" + ".java"), option + "/java/mgr/ApiManagerImpl.java", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiManager" + ".java"), option + "/java/module/mgr/ApiManager.java", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiManagerImpl" + ".java"), option + "/java/module/mgr/ApiManagerImpl.java", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Table table : md.getTables()) {
|
|
|
|
|
ctx.put("table", table);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Manager" + ".java"), option + "/java/mgr/manager.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "ManagerImpl" + ".java"), option + "/java/mgr/managerImpl.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "Manager" + ".java"), option + "/java/module/mgr/manager.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "ManagerImpl" + ".java"), option + "/java/module/mgr/managerImpl.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -390,37 +393,37 @@ public class SpringBootCallable implements Callable {
|
|
|
|
|
ctx.put("date", new Date());
|
|
|
|
|
|
|
|
|
|
if (md.getModuleName().equals("api")) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiExampleRequest" + ".java"), option + "/java/req/ApiExampleRequest.java", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiExampleRequest" + ".java"), option + "/java/module/req/ApiExampleRequest.java", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Table table : md.getTables()) {
|
|
|
|
|
ctx.put("table", table);
|
|
|
|
|
|
|
|
|
|
if (table.getCreate()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "CreateRequest" + ".java"), option + "/java/req/createRequestClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "CreateRequest" + ".java"), option + "/java/module/req/createRequestClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getDelete()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "DeleteRequest" + ".java"), option + "/java/req/deleteRequestClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "DeleteRequest" + ".java"), option + "/java/module/req/deleteRequestClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getUpdate()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "UpdateRequest" + ".java"), option + "/java/req/updateRequestClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "UpdateRequest" + ".java"), option + "/java/module/req/updateRequestClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getFind()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "FindRequest" + ".java"), option + "/java/req/findRequestClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "FindRequest" + ".java"), option + "/java/module/req/findRequestClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getGet()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetRequest" + ".java"), option + "/java/req/getRequestClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetRequest" + ".java"), option + "/java/module/req/getRequestClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getSearch()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchRequest" + ".java"), option + "/java/req/searchRequestClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchRequest" + ".java"), option + "/java/module/req/searchRequestClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
if (table.getGetAll()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllRequest" + ".java"), option + "/java/req/getAllRequestClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllRequest" + ".java"), option + "/java/module/req/getAllRequestClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -447,37 +450,37 @@ public class SpringBootCallable implements Callable {
|
|
|
|
|
ctx.put("date", new Date());
|
|
|
|
|
|
|
|
|
|
if (md.getModuleName().equals("api")) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiExampleResponse" + ".java"), option + "/java/rsp/ApiExampleResponse.java", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), "ApiExampleResponse" + ".java"), option + "/java/module/rsp/ApiExampleResponse.java", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Table table : md.getTables()) {
|
|
|
|
|
ctx.put("table", table);
|
|
|
|
|
|
|
|
|
|
if (table.getCreate()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "CreateResponse" + ".java"), option + "/java/rsp/createResponseClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "CreateResponse" + ".java"), option + "/java/module/rsp/createResponseClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getDelete()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "DeleteResponse" + ".java"), option + "/java/rsp/deleteResponseClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "DeleteResponse" + ".java"), option + "/java/module/rsp/deleteResponseClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getUpdate()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "UpdateResponse" + ".java"), option + "/java/rsp/updateResponseClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "UpdateResponse" + ".java"), option + "/java/module/rsp/updateResponseClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getFind()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "FindResponse" + ".java"), option + "/java/rsp/findResponseClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "FindResponse" + ".java"), option + "/java/module/rsp/findResponseClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getGet()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetResponse" + ".java"), option + "/java/rsp/getResponseClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetResponse" + ".java"), option + "/java/module/rsp/getResponseClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (table.getSearch()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchResponse" + ".java"), option + "/java/rsp/searchResponseClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "SearchResponse" + ".java"), option + "/java/module/rsp/searchResponseClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
if (table.getGetAll()) {
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllResponse" + ".java"), option + "/java/rsp/getAllResponseClass.ftl", ctx);
|
|
|
|
|
freeMarkerManager.outputTemp(new File(root.getAbsolutePath(), Tool.lineToClassName(table.getTableName()) + "GetAllResponse" + ".java"), option + "/java/module/rsp/getAllResponseClass.ftl", ctx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|