From cd3982f1435ac05296120db197664d469604e244 Mon Sep 17 00:00:00 2001 From: whyclxw <http://whyclxw@118.89.139.230:10101/r/~whyclxw/IdeaTest.git> Date: 星期五, 16 四月 2021 11:19:40 +0800 Subject: [PATCH] 代码生成器 --- src/test/java/com/example/lxw/GeneratorCode.java | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/example/lxw/GeneratorCode.java b/src/test/java/com/example/lxw/GeneratorCode.java index 1ec38e2..9d6c45e 100644 --- a/src/test/java/com/example/lxw/GeneratorCode.java +++ b/src/test/java/com/example/lxw/GeneratorCode.java @@ -12,6 +12,8 @@ import com.baomidou.mybatisplus.generator.config.po.TableFill; import com.baomidou.mybatisplus.generator.config.rules.DateType; import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; +import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; + import java.util.ArrayList; import java.util.ArrayList; @@ -47,23 +49,23 @@ mpg.setDataSource(dsc); //3、包的配置 PackageConfig pc = new PackageConfig(); - pc.setModuleName("blog"); pc.setParent("com.generator"); - pc.setEntity("entity"); + pc.setEntity("pojo"); pc.setMapper("mapper"); pc.setService("service"); pc.setController("controller"); mpg.setPackageInfo(pc); //4、策略配置 StrategyConfig strategy = new StrategyConfig(); + strategy.setTablePrefix("tb"); strategy.setInclude("tb_user_inf","tb_user_battgroup_baojigroup","tb_user_battgroup_baojigroup_battgroup","tb_user_battgroup_baojigroup_usr"); // 设置要映射的表名 - strategy.setNaming(NamingStrategy.underline_to_camel); + strategy.setNaming(NamingStrategy.underline_to_camel); strategy.setColumnNaming(NamingStrategy.underline_to_camel); strategy.setEntityLombokModel(true); // 自动lombok; strategy.setLogicDeleteFieldName("deleted"); // 自动填充配置 TableFill gmtCreate = new TableFill("gmt_create", FieldFill.INSERT); - TableFill gmtModified = new TableFill("gmt_modified",FieldFill.INSERT_UPDATE); + TableFill gmtModified = new TableFill("gmt_modified", FieldFill.INSERT_UPDATE); ArrayList<TableFill> tableFills = new ArrayList<>(); tableFills.add(gmtCreate); tableFills.add(gmtModified); @@ -71,8 +73,8 @@ // 乐观锁 strategy.setVersionFieldName("version"); strategy.setRestControllerStyle(true); - strategy.setControllerMappingHyphenStyle(true); //localhost:8080/hello_id_2mpg.setStrategy(strategy); + strategy.setControllerMappingHyphenStyle(true); //localhost:8080/hello_id_2 + mpg.setStrategy(strategy); mpg.execute(); //执行 - } } -- Gitblit v1.9.1