use of com.baomidou.mybatisplus.generator.keywords.MySqlKeyWordsHandler in project xuxiaowei-cloud by xuxiaowei-cloud.
the class MyBatisPlusGeneratorTests method main.
public static void main(String[] args) {
DataSourceConfig.Builder dataSourceConfig = new DataSourceConfig.Builder("jdbc:mysql://127.0.0.1:3306/xuxiaowei_cloud", "root", "root").dbQuery(new MySqlQuery()).schema("users").typeConvert(new MySqlTypeConvert()).keyWordsHandler(new MySqlKeyWordsHandler());
String userDir = System.getProperty("user.dir");
String fileSeparator = System.getProperty("file.separator");
List<Module> moduleList = Arrays.asList(new Module("authorization-server", "cloud.xuxiaowei.authorizationserver"), new Module("cloud-commons-parent" + fileSeparator + "cloud-starter-core", "cloud.xuxiaowei.core"), new Module("resource-server", "cloud.xuxiaowei.resourceserver"));
System.out.println("项目文件夹:" + userDir);
System.out.println("模块列表:");
for (int i = 0; i < moduleList.size(); i++) {
Module module = moduleList.get(i);
System.out.println("序号:" + i + ":" + module.getModuleFolder() + ":" + module.getPackageName());
}
int moduleNumber = scannerInt("请输入模块名序号?");
Module module = moduleList.get(moduleNumber);
String moduleFolder = module.getModuleFolder();
String packageName = module.getPackageName();
String[] packageNameSplit = packageName.split("\\.");
String xmlFolder = packageNameSplit[packageNameSplit.length - 1];
String mainFolder = userDir + fileSeparator + moduleFolder + fileSeparator + "src" + fileSeparator + "main";
String javaDir = mainFolder + fileSeparator + "java";
String xmlDir = mainFolder + fileSeparator + "resources" + fileSeparator + "mapper" + fileSeparator + xmlFolder;
System.out.println("java 输出目录:" + javaDir);
System.out.println("xml 输出目录:" + xmlDir);
FastAutoGenerator.create(dataSourceConfig).globalConfig((scanner, builder) -> {
builder.author(scanner.apply("请输入作者名称?"));
// 禁止打开输出目录
builder.disableOpenDir();
// 输出目录
builder.outputDir(javaDir);
}).packageConfig((scanner, builder) -> {
builder.parent(packageName);
builder.pathInfo(Collections.singletonMap(OutputFile.xml, xmlDir));
}).strategyConfig((scanner, builder) -> builder.addInclude(getTables(scanner.apply("请输入表名,多个英文逗号分隔?所有输入 all"))).controllerBuilder().enableRestStyle().enableHyphenStyle().mapperBuilder().enableBaseResultMap().entityBuilder().enableLombok().addTableFills(new Column("create_date", FieldFill.INSERT), new Column("update_date", FieldFill.UPDATE), new Column("create_username", FieldFill.INSERT), new Column("update_username", FieldFill.UPDATE)).logicDeleteColumnName("deleted").build()).execute();
}
Aggregations