| package com.poilearn.generate; |
| |
| import com.baomidou.mybatisplus.annotation.FieldFill; |
| import com.baomidou.mybatisplus.annotation.IdType; |
| import com.baomidou.mybatisplus.generator.FastAutoGenerator; |
| import com.baomidou.mybatisplus.generator.config.TemplateType; |
| import com.baomidou.mybatisplus.generator.fill.Column; |
| import org.apache.commons.lang3.StringUtils; |
| |
| import java.io.File; |
| |
| |
| * 代码生成 |
| */ |
| public class VelocityGen { |
| |
| |
| |
| * 启动 |
| **/ |
| public static void main(String[] args) { |
| commonCreate(); |
| } |
| |
| |
| * 代码生成 |
| */ |
| public static void commonCreate() { |
| |
| System.setProperty("file.encoding", "UTF-8"); |
| |
| |
| |
| String assembleIcpCodePath = System.getProperty("user.dir"); |
| |
| |
| String finalProjectPath = assembleIcpCodePath + File.separator |
| |
| + File.separator + GenPathEnum.MODULE_ANALYSIS_FLOW.getName()//*/ |
| ; |
| |
| |
| |
| String author = "dkx"; |
| |
| String packageName = "com"; |
| |
| String moduleName = "poilearn"; |
| |
| String tables = "tab_shop"; |
| |
| String tablePrefix = "tab_"; |
| |
| |
| |
| FastAutoGenerator.create("jdbc:mysql://localhost:3306/test?characterEncoding=utf-8&serverTimezone=UTC&useUnicode=true", "root", "dkx..") |
| |
| .globalConfig(builder -> { |
| builder.author(author) |
| |
| .disableOpenDir() |
| .outputDir(finalProjectPath + "/src/main/java"); |
| }) |
| |
| .packageConfig(builder -> { |
| builder.parent(packageName) |
| .moduleName(moduleName); |
| }) |
| |
| .templateConfig(builder -> { |
| |
| |
| builder.disable(TemplateType.XML); |
| |
| |
| |
| |
| |
| }) |
| |
| .strategyConfig(builder -> { |
| builder.entityBuilder().enableLombok() |
| .logicDeleteColumnName("is_deleted") |
| .addTableFills(new Column("create_time", FieldFill.INSERT)) |
| .addTableFills(new Column("create_by", FieldFill.INSERT)) |
| .addTableFills(new Column("update_time", FieldFill.UPDATE)) |
| .addTableFills(new Column("update_by", FieldFill.UPDATE)) |
| .addTableFills(new Column("id", FieldFill.INSERT)) |
| .enableTableFieldAnnotation() |
| .idType(IdType.ASSIGN_UUID) |
| .enableFileOverride() |
| ; |
| |
| if (StringUtils.isNotBlank(tablePrefix)) { |
| |
| builder.addTablePrefix(tablePrefix); |
| |
| } |
| builder.controllerBuilder() |
| .enableHyphenStyle() |
| .enableRestStyle(); |
| builder.addInclude(tables); |
| }) |
| |
| .execute(); |
| } |
| } |