| | |
| | | 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; |
| | |
| | | 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); |
| | |
| | | // 乐观锁 |
| | | 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(); //执行 |
| | | |
| | | } |
| | | } |