|
@@ -1,8 +1,11 @@
|
|
package com.alvin;
|
|
package com.alvin;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
|
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
|
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
|
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
|
|
|
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
|
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
|
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
|
|
|
+import com.baomidou.mybatisplus.generator.fill.Column;
|
|
|
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
|
|
|
@@ -14,7 +17,7 @@ public class Generator {
|
|
String db_username = "root";
|
|
String db_username = "root";
|
|
String db_password = "root";
|
|
String db_password = "root";
|
|
|
|
|
|
- String javaDir = "C:\\Users\\root\\IdeaProjects\\java-base-maven\\mybatis-test\\src\\main\\java";
|
|
|
|
|
|
+ String javaDir = "C:/code";
|
|
String parentPackage = "com.alvin";
|
|
String parentPackage = "com.alvin";
|
|
String moduleName = "db";
|
|
String moduleName = "db";
|
|
String tableName = "access_role";
|
|
String tableName = "access_role";
|
|
@@ -30,6 +33,7 @@ public class Generator {
|
|
FastAutoGenerator.create(db_url, db_username, db_password)
|
|
FastAutoGenerator.create(db_url, db_username, db_password)
|
|
.globalConfig(builder -> {
|
|
.globalConfig(builder -> {
|
|
builder.author(author) // 设置作者
|
|
builder.author(author) // 设置作者
|
|
|
|
+ .dateType(DateType.ONLY_DATE) // 设置日期为 Date
|
|
//.enableSwagger() // 开启 swagger 模式
|
|
//.enableSwagger() // 开启 swagger 模式
|
|
.fileOverride() // 覆盖已生成文件
|
|
.fileOverride() // 覆盖已生成文件
|
|
.outputDir(javaDir); // 指定输出目录
|
|
.outputDir(javaDir); // 指定输出目录
|
|
@@ -41,7 +45,15 @@ public class Generator {
|
|
})
|
|
})
|
|
.strategyConfig(builder -> {
|
|
.strategyConfig(builder -> {
|
|
builder.addInclude(tableName) // 设置需要生成的表名
|
|
builder.addInclude(tableName) // 设置需要生成的表名
|
|
- .addTablePrefix(tablePrefix); // 设置过滤表前缀
|
|
|
|
|
|
+ .addTablePrefix(tablePrefix)
|
|
|
|
+ .entityBuilder()
|
|
|
|
+ .enableLombok()
|
|
|
|
+ .addTableFills(
|
|
|
|
+ new Column("create_time", FieldFill.INSERT),
|
|
|
|
+ new Column("update_time", FieldFill.INSERT_UPDATE)
|
|
|
|
+ )
|
|
|
|
+ ;
|
|
|
|
+
|
|
})
|
|
})
|
|
.templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
|
.templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
|
.execute();
|
|
.execute();
|