db.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package models
  2. import (
  3. "eta/eta_forum_admin/models/company"
  4. "eta/eta_forum_admin/models/eta_business"
  5. "eta/eta_forum_admin/models/eta_training_video"
  6. "eta/eta_forum_admin/models/eta_trial"
  7. "eta/eta_forum_admin/models/help_doc"
  8. "eta/eta_forum_admin/models/system"
  9. "eta/eta_forum_admin/utils"
  10. "github.com/beego/beego/v2/client/orm"
  11. _ "github.com/go-sql-driver/mysql"
  12. "time"
  13. )
  14. func init() {
  15. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  16. orm.SetMaxIdleConns("default", 50)
  17. orm.SetMaxOpenConns("default", 100)
  18. db, _ := orm.GetDB("default")
  19. db.SetConnMaxLifetime(10 * time.Minute)
  20. orm.Debug = true
  21. orm.DebugLog = orm.NewLog(utils.Binlog)
  22. initChart()
  23. initEdbData()
  24. initUser()
  25. initETATrial()
  26. initEtaBusiness()
  27. initSystem()
  28. // ETA版本更新日志
  29. initEtaVersionUpdateLog()
  30. // 帮助文档
  31. initHelpDoc()
  32. // ETA培训视频相关表
  33. initEtaTrainingVideo()
  34. }
  35. // initChart 图表 数据表
  36. func initChart() {
  37. orm.RegisterModel(
  38. new(ChartClassify),
  39. new(ChartInfo),
  40. new(ChartEdbMapping),
  41. new(ChartTheme),
  42. new(ChartThemeType),
  43. new(ChartInfoLog),
  44. new(SearchKeyword),
  45. )
  46. }
  47. // initEdbData 指标服务 数据表
  48. func initEdbData() {
  49. orm.RegisterModel(
  50. new(EdbInfoCalculateMapping),
  51. new(EdbInfo),
  52. )
  53. }
  54. // 初始化用户服务
  55. func initUser() {
  56. orm.RegisterModel(
  57. new(system.SysSession),
  58. new(system.SysUserLoginRecord),
  59. new(system.Admin),
  60. new(system.AdminOperateRecord),
  61. )
  62. }
  63. // initETATrial ETA试用
  64. func initETATrial() {
  65. orm.RegisterModel(
  66. new(eta_trial.EtaTrial),
  67. new(eta_trial.EtaTrialApproval),
  68. //new(eta_trial.EtaTrialQuestionnaire),
  69. new(company.CompanyApprovalMessage),
  70. )
  71. }
  72. // initEtaBusiness ETA商家相关表
  73. func initEtaBusiness() {
  74. orm.RegisterModel(
  75. new(eta_business.EtaBusiness), // ETA商家表
  76. new(eta_business.EtaBusinessContract), // ETA合同表
  77. new(eta_business.EtaBusinessOperationRecord), // ETA操作记录表
  78. new(eta_business.EtaBusinessMenu), // ETA商家菜单表
  79. new(eta_business.EtaBusinessMenuRelate), // ETA商家菜单关联表
  80. new(eta_business.EtaBusinessConfigRelate), // ETA商家配置关联表
  81. new(eta_business.EtaBusinessMenuIcon), // ETA商家菜单icon表
  82. new(User), // 商家用户表
  83. new(eta_business.BusinessChartClassifyPermission), //商家图表权限表
  84. )
  85. }
  86. // initSystem 系统表 数据表
  87. func initSystem() {
  88. orm.RegisterModel(
  89. new(system.SysRole),
  90. new(system.SysMenuButton),
  91. new(system.SysRoleAdmin), //管理员账号和角色映射表
  92. new(system.SysRoleMenu),
  93. )
  94. }
  95. // initEtaVersionUpdateLog ETA版本更新日志
  96. func initEtaVersionUpdateLog() {
  97. orm.RegisterModel(
  98. new(EtaVersionUpdateLog), // 更新日志表
  99. )
  100. }
  101. func initHelpDoc() {
  102. //注册对象
  103. orm.RegisterModel(
  104. new(help_doc.HelpDocClassify), //分类
  105. new(help_doc.HelpDoc), //文章
  106. )
  107. }
  108. // initEtaTrainingVideo ETA培训视频相关表
  109. func initEtaTrainingVideo() {
  110. orm.RegisterModel(
  111. new(eta_training_video.EtaTrainingVideo), // 视频表
  112. new(eta_training_video.EtaTrainingVideoOpLog), // 视频操作记录表
  113. //new(eta_training_video.EtaTrainingVideoViewLog), // 视频访问记录表
  114. new(eta_training_video.EtaTrainingVideoTag), // 标签表
  115. new(eta_training_video.EtaTrainingVideoTagRelate), // 标签关联表
  116. new(eta_training_video.EtaTrainingVideoClassify), // 分类表
  117. new(eta_training_video.EtaTrainingVideoClassifyRelate), // 分类关联表
  118. )
  119. }