package com.zxh.ioms;
import cn.hutool.core.util.StrUtil;
import com.github.davidfantasy.mybatisplus.generatorui.GeneratorConfig;
import com.github.davidfantasy.mybatisplus.generatorui.MybatisPlusToolsApplication;
import com.github.davidfantasy.mybatisplus.generatorui.mbp.NameConverter;
import com.google.common.base.Strings;
/**
* 代码一键生成工具
*/
public class GeberatorUIServer {
public static void main(String[] args) {
GeneratorConfig config = GeneratorConfig.builder().jdbcUrl("jdbc:mysql://192.168.0.1:3306/ioms?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai")
.userName("user")
.password("xxxxxx")
.driverClassName("com.mysql.cj.jdbc.Driver")
//数据库schema,POSTGRE_SQL,ORACLE,DB2类型的数据库需要指定
// .schemaName("chuangkeyun")
//如果需要修改各类生成文件的默认命名规则,可自定义一个NameConverter实例,覆盖相应的名称转换方法:
.nameConverter(new NameConverter() {
@Override
public String entityNameConvert(String tableName) {
if (Strings.isNullOrEmpty(tableName)) {
return "";
} else {
return StrUtil.upperFirst(StrUtil.toCamelCase(tableName.toLowerCase()));
}
}
/**
* 自定义Service类文件的名称规则
*/
@Override
public String serviceNameConvert(String tableName) {
return this.entityNameConvert(tableName) + "Service";
}
/**
* 自定义Controller类文件的名称规则
*/
@Override
public String controllerNameConvert(String tableName) {
return this.entityNameConvert(tableName) + "Controller";
}
})
.basePackage("com.zxh.ioms")
.port(8080)
.build();
MybatisPlusToolsApplication.run(config);
}
}