CodeGenerator.java 5.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //package com.ydtech.utils.genMybatis;
  2. //import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  3. //import com.baomidou.mybatisplus.generator.FastAutoGenerator;
  4. //import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
  5. //
  6. //import java.util.ArrayList;
  7. //import java.util.List;
  8. ///**
  9. // * @author gws
  10. // * @description:TODO
  11. // * @date 2023-11-22 18:04
  12. // */
  13. //public class CodeGenerator {
  14. //
  15. //
  16. // public static void main(String[] args) {
  17. // /*
  18. // 特别注意:生成的时间类型均为:“LocalDateTime”格式,需要假如以下注解方可正常使用
  19. // @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//用于指定日期/时间类型的属性在序列化为JSON字符串时的格式。
  20. // @JsonDeserialize(using = LocalDateTimeDeserializer.class)//用于指定反序列化时使用的自定义类,LocalDateTimeDeserializer是一个实现了JsonDeserializer接口的类,可以将JSON字符串转换为LocalDateTime对象
  21. // @JsonSerialize(using = LocalDateTimeSerializer.class)//用于指定序列化时使用的自定义类,LocalDateTimeSerializer是一个实现了JsonSerializer接口的类,可以将LocalDateTime对象转换为JSON字符串
  22. // */
  23. //
  24. //
  25. // //数据库连接
  26. // String url = "jdbc:mysql://47.92.254.66:3306/zgdd?serverTimezone=Asia/Shanghai&allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&rewriteBatchedStatements=true";//数据库url
  27. // String username = "root";//账号
  28. // String password = "@RqGHG#KZ*C9ytkQ";//密码
  29. // //String module = "up";//模块名
  30. // //全局配置参数
  31. // String author = "gws";//作者
  32. // //String outputDir = System.getProperty("user.dir")+"\\"+module+"\\src\\main\\java";//指定输出目录
  33. // String outputDir = System.getProperty("user.dir")+"\\src\\main\\java";//指定输出目录
  34. //
  35. // //包配置参数
  36. // String parent = "com.ydtech.modules";//父包名
  37. // String moduleName = "fnc";//父包模块名
  38. // String entity = "entity";//Entity 实体类包名
  39. // String mapper = "dao";//Mapper 包名
  40. // String mapperXml = "xml";//Mapper XML 包名
  41. // String service = "service";//Service 包名
  42. // String serviceImpl = "service.impl";//Service Impl 包名
  43. // String controller = "controller";//Controller 包名
  44. // //要生成的数据库表
  45. // List<String> tables = new ArrayList<>();
  46. // tables.add("ins_ply_settle_detail");//表名
  47. // tables.add("ins_ply_settle");//表名
  48. // tables.add("ins_ply_settle_hx");//表名
  49. // //开始生成
  50. // FastAutoGenerator.create(url,username,password)
  51. // //全局配置
  52. // .globalConfig(builder -> {
  53. // builder.author(author)
  54. // .outputDir(outputDir)
  55. // .enableSwagger()//开启swagger
  56. // .commentDate("yyyy-MM-dd");//注释日期
  57. // })
  58. // //包配置
  59. // .packageConfig(builder -> {
  60. // builder.parent(parent)
  61. // .moduleName(moduleName)
  62. // .entity(entity)
  63. // .mapper(mapper)
  64. // .xml(mapperXml)
  65. // .service(service)
  66. // .serviceImpl(serviceImpl)
  67. // .controller(controller);
  68. // })
  69. // //策略配置
  70. // .strategyConfig(builder -> {
  71. // builder.addInclude(tables)
  72. // //开启生成实体类
  73. // .entityBuilder()
  74. // .enableLombok()//开启 lombok 模型
  75. // .enableTableFieldAnnotation()//开启生成实体时生成字段注解
  76. // //开启生成mapper
  77. // .mapperBuilder()
  78. // .enableBaseResultMap()//启用 BaseResultMap 生成
  79. // .superClass(BaseMapper.class)//设置父类
  80. // .enableMapperAnnotation()//开启 @Mapper 注解
  81. // .formatMapperFileName("%sMapper")//格式化 mapper 文件名称
  82. // .formatXmlFileName("%sMapper")//格式化 xml 实现类文件名称
  83. // //开启生成service及impl
  84. // .serviceBuilder()
  85. // .formatServiceFileName("%sService")//格式化 service 接口文件名称
  86. // .formatServiceImplFileName("%sServiceImpl")//格式化 service 实现类文件名称
  87. // //开启生成controller
  88. // .controllerBuilder()
  89. // // 映射路径使用连字符格式,而不是驼峰
  90. // .enableHyphenStyle()
  91. // .formatFileName("%sController")//格式化文件名称
  92. // .enableRestStyle();;
  93. // })
  94. // .templateEngine(new VelocityTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
  95. // //.templateConfig(builder -> builder.controller(""))//关闭生成controller
  96. // .execute();
  97. // }
  98. //}