Generator.kt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package com.gxzc.zen
  2. import com.baomidou.mybatisplus.generator.AutoGenerator
  3. import com.baomidou.mybatisplus.generator.config.DataSourceConfig
  4. import com.baomidou.mybatisplus.generator.config.GlobalConfig
  5. import com.baomidou.mybatisplus.generator.config.StrategyConfig
  6. import com.baomidou.mybatisplus.generator.config.rules.DbType
  7. import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy
  8. /**
  9. *
  10. * @author NorthLan
  11. * @date 2018/1/24
  12. * @url https://noahlan.me
  13. */
  14. class Generator {
  15. fun main(args: Array<String>) {
  16. val mpg = AutoGenerator()
  17. // 全局配置
  18. val gc = GlobalConfig()
  19. with(gc) {
  20. outputDir = "D://Test"
  21. isFileOverride = true
  22. isActiveRecord = false
  23. isEnableCache = false
  24. isOpen = true
  25. author = "NorthLan"
  26. isKotlin = true
  27. isBaseResultMap = true
  28. mapperName = "%sDao"
  29. xmlName = "%sDao"
  30. serviceName = "I%sService"
  31. serviceImplName = "%sServiceImpl"
  32. }
  33. mpg.globalConfig = gc
  34. // 数据源
  35. val dataSource = DataSourceConfig()
  36. with(dataSource) {
  37. dbType = DbType.MYSQL
  38. // typeConvert
  39. driverName = "com.mysql.jdbc.Driver"
  40. username = "root"
  41. password = "root"
  42. url = "jdbc:mysql://127.0.0.1:3306/rest?characterEncoding=utf8"
  43. }
  44. mpg.dataSource = dataSource
  45. // 策略配置
  46. val strategyConfig = StrategyConfig()
  47. with(strategyConfig) {
  48. setDbColumnUnderline(true)
  49. // setTablePrefix()
  50. naming = NamingStrategy.underline_to_camel
  51. setInclude("user")
  52. setExclude("")
  53. setSuperEntityClass("com.gxzc.zen.persistence.ZenBaseDao")
  54. }
  55. }
  56. }