|
@@ -13,29 +13,27 @@ public class Generator {
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
- String db_url = "jdbc:mysql://mysql.aimpdev.svc.k5.bigtree.zone:3306/aimp_model";
|
|
|
|
- String db_username = "test_user";
|
|
|
|
- String db_password = "tmOxmmc+3jznq2cX";
|
|
|
|
-
|
|
|
|
- String javaDir = "/Users/alvin/bigtree/aimp-manager/aimp-manager-service/src/main/java";
|
|
|
|
- String parentPackage = "com.bigtreefinance.aimp.manager";
|
|
|
|
-
|
|
|
|
- //String javaDir = "/Users/alvin/bigtree/aimp-actuator/aimp-actuator-service/src/main/java";
|
|
|
|
- //String parentPackage = "com.bigtreefinance.aimp.actuator";
|
|
|
|
-
|
|
|
|
- String tableName = "aimp_list,aimp_model,aimp_model_log,aimp_model_version,aimp_node_config,aimp_operation_log,aimp_process,aimp_process_node,aimp_sample,";
|
|
|
|
- //String tableName = "aimp_sample";
|
|
|
|
-
|
|
|
|
- String author = "bigtree";
|
|
|
|
- String tablePrefix = "";
|
|
|
|
-
|
|
|
|
- generatorToFile(db_url, db_username, db_password, author, javaDir, parentPackage, tableName, tablePrefix);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- private static void generatorToFile(String db_url, String db_username, String db_password, String author,
|
|
|
|
- String javaDir, String parentPackage, String tableName, String tablePrefix) {
|
|
|
|
- FastAutoGenerator.create(db_url, db_username, db_password)
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 生成文件
|
|
|
|
+ *
|
|
|
|
+ * @param db_url db url
|
|
|
|
+ * @param db_username 数据库用户名
|
|
|
|
+ * @param db_password 数据库密码
|
|
|
|
+ * @param author 作者
|
|
|
|
+ * @param javaDir java dir
|
|
|
|
+ * @param parentPackage 父包
|
|
|
|
+ * @param tableName 表名
|
|
|
|
+ * @param tablePrefix 表前缀
|
|
|
|
+ * @param controller 是否生成 controller
|
|
|
|
+ * @param service 是否生成 service
|
|
|
|
+ * @param serviceImpl 是否生成 serviceImpl
|
|
|
|
+ */
|
|
|
|
+ public static void generatorToFile(String db_url, String db_username, String db_password, String author,
|
|
|
|
+ String javaDir, String parentPackage, String tableName, String tablePrefix,
|
|
|
|
+ Boolean controller, Boolean service, Boolean serviceImpl) {
|
|
|
|
+ FastAutoGenerator generator = FastAutoGenerator.create(db_url, db_username, db_password)
|
|
//===全局配置
|
|
//===全局配置
|
|
.globalConfig(builder -> {
|
|
.globalConfig(builder -> {
|
|
builder.author(author) // 设置作者
|
|
builder.author(author) // 设置作者
|
|
@@ -75,16 +73,25 @@ public class Generator {
|
|
for (String s : tablePrefix.split(",")) {
|
|
for (String s : tablePrefix.split(",")) {
|
|
builder.addTablePrefix(s.trim());
|
|
builder.addTablePrefix(s.trim());
|
|
}
|
|
}
|
|
-
|
|
|
|
})
|
|
})
|
|
- .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
|
|
|
- .templateConfig(builder -> builder.entity("templates/entity1.java"))
|
|
|
|
- //.templateConfig(builder -> builder.controller("templates/controller1.java")) // 设置为空则不会生成该文件
|
|
|
|
- //.templateConfig(builder -> builder.service("templates/service1.java"))
|
|
|
|
- //.templateConfig(builder -> builder.serviceImpl("templates/serviceImpl1.java"))
|
|
|
|
- .templateConfig(builder -> builder.controller("")) // 设置为空则不会生成该文件
|
|
|
|
- .templateConfig(builder -> builder.service(""))
|
|
|
|
- .templateConfig(builder -> builder.serviceImpl(""))
|
|
|
|
- .execute();
|
|
|
|
|
|
+ .templateEngine(new FreemarkerTemplateEngine())// 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
|
|
|
+ .templateConfig(builder -> builder.entity("templates/entity1.java"));
|
|
|
|
+
|
|
|
|
+ if (!controller) {
|
|
|
|
+ generator.templateConfig(builder -> builder.entity("")); // 设置为空则不会生成该文件
|
|
|
|
+ } else {
|
|
|
|
+ generator.templateConfig(builder -> builder.entity("templates/controller1.java"));
|
|
|
|
+ }
|
|
|
|
+ if (!service) {
|
|
|
|
+ generator.templateConfig(builder -> builder.entity(""));
|
|
|
|
+ } else {
|
|
|
|
+ generator.templateConfig(builder -> builder.entity("templates/service1.java"));
|
|
|
|
+ }
|
|
|
|
+ if (!serviceImpl) {
|
|
|
|
+ generator.templateConfig(builder -> builder.entity(""));
|
|
|
|
+ } else {
|
|
|
|
+ generator.templateConfig(builder -> builder.entity("templates/serviceImpl1.java"));
|
|
|
|
+ }
|
|
|
|
+ generator.execute();
|
|
}
|
|
}
|
|
}
|
|
}
|