use of com.baomidou.mybatisplus.generator.config.rules.IColumnType in project orion-ops by lijiahangmax.
the class CodeGenerator method runGenerator.
/**
* 代码生成器
*/
private static void runGenerator() {
// 全局配置
GlobalConfig gbConfig = new GlobalConfig().setActiveRecord(false).setAuthor(Const.ORION_AUTHOR).setOutputDir("D:/MP/").setFileOverride(true).setIdType(IdType.AUTO).setServiceName("%sService").setServiceImplName("%sServiceImpl").setEntityName("%sDO").setMapperName("%sDAO").setXmlName("%sMapper").setControllerName("%sController").setSwagger2(false).setKotlin(false).setBaseResultMap(true).setEnableCache(false).setDateType(DateType.ONLY_DATE).setBaseColumnList(true);
// 数据源配置
DataSourceConfig dsConfig = new DataSourceConfig().setDbType(DbType.MYSQL).setDriverName("com.mysql.cj.jdbc.Driver").setUrl("jdbc:mysql://localhost:3306/orion-ops?characterEncoding=utf8").setUsername("root").setPassword("admin123").setTypeConvert(new MySqlTypeConvert() {
@Override
public IColumnType processTypeConvert(GlobalConfig globalConfig, String fieldType) {
if (fieldType.toLowerCase().contains("tinyint")) {
return DbColumnType.INTEGER;
}
return super.processTypeConvert(globalConfig, fieldType);
}
});
// 策略配置
StrategyConfig stConfig = new StrategyConfig().setCapitalMode(true).setEntityTableFieldAnnotationEnable(true).setEntityLombokModel(true).setRestControllerStyle(true).setControllerMappingHyphenStyle(false).setEntityBooleanColumnRemoveIsPrefix(false).setNaming(NamingStrategy.underline_to_camel).setEntityColumnConstant(false).setChainModel(false).setTablePrefix("").setFieldPrefix("").setInclude("web_side_message");
// 包名策略配置
PackageConfig pkConfig = new PackageConfig().setParent("com.orion.ops").setMapper("dao").setService("service").setServiceImpl("service.impl").setController("controller").setEntity("entity.domain").setXml("mapper");
// 整合配置
AutoGenerator ag = new AutoGenerator().setGlobalConfig(gbConfig).setDataSource(dsConfig).setStrategy(stConfig).setPackageInfo(pkConfig);
// 执行
ag.execute();
}
Aggregations