| | |
| | | import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.generator.FastAutoGenerator; |
| | | import com.baomidou.mybatisplus.generator.config.*; |
| | | import com.baomidou.mybatisplus.generator.config.GlobalConfig; |
| | | import com.baomidou.mybatisplus.generator.config.OutputFile; |
| | | import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert; |
| | | import com.baomidou.mybatisplus.generator.config.po.TableField; |
| | | import com.baomidou.mybatisplus.generator.config.rules.DbColumnType; |
| | |
| | | // 演示例子,执行 main 方法控制台输入模块表名回车自动生成对应项目目录中 |
| | | public class CodeGenerator { |
| | | |
| | | public static String database_url = "jdbc:mysql://127.0.0.1:3306/product-inventory-management"; |
| | | public static String database_url = "jdbc:mysql://localhost:3307/product-inventory-management-new-pro"; |
| | | public static String database_username = "root"; |
| | | public static String database_password= "123456"; |
| | | public static String author = "芯导软件(江苏)有限公司"; |
| | | public static String model = "collaborativeApproval"; // 模块 |
| | | public static String model = "technology"; // 模块 |
| | | public static String setParent = "com.ruoyi."+ model; // 包路径 |
| | | public static String tablePrefix = ""; // 设置过滤表前缀 |
| | | public static void main(String[] args) { |
| | |
| | | .packageConfig(builder -> { |
| | | builder.entity("pojo"); |
| | | builder.parent(setParent) // 设置父包名 |
| | | .pathInfo(Collections.singletonMap(OutputFile.xml, projectPath + "/src/main/resources/"+model+"/mapper")); // 设置mapperXml生成路径 |
| | | .pathInfo(Collections.singletonMap(OutputFile.xml, projectPath + "/src/main/resources/mapper/"+model)); // 设置mapperXml生成路径 |
| | | }) |
| | | // 策略配置 |
| | | .strategyConfig(builder -> { |
| | |
| | | new Column("update_time", FieldFill.INSERT_UPDATE), |
| | | new Column("create_user", FieldFill.INSERT), |
| | | new Column("update_user", FieldFill.INSERT_UPDATE), |
| | | new Column("tenant_id", FieldFill.INSERT) |
| | | new Column("dept_id", FieldFill.INSERT) |
| | | ) |
| | | .idType(IdType.AUTO) // 自增主键 |
| | | |
| | |
| | | .mapperBuilder() |
| | | .enableFileOverride() // 覆盖已生成Mapper文件 |
| | | .enableBaseResultMap() // 自动生成resultMap |
| | | .mapperAnnotation(org.apache.ibatis.annotations.Mapper.class) |
| | | |
| | | // Service 策略配置 |
| | | .serviceBuilder() |
| | | .formatServiceFileName("%sService") //格式化 service 接口文件名称,%s进行匹配表名,如 UserService |
| | |
| | | StringBuilder help = new StringBuilder(); |
| | | help.append("请输入" + tip + ":"); |
| | | System.out.println(help.toString()); |
| | | if (scanner.hasNext()) { |
| | | String ipt = scanner.next(); |
| | | |
| | | if (scanner.hasNextLine()) { |
| | | String ipt = scanner.nextLine(); |
| | | if (StringUtils.isNotBlank(ipt)) { |
| | | return ipt; |
| | | } |