db.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. "hongze/hongze_task/models/company_approval"
  5. "hongze/hongze_task/models/company_contract"
  6. "hongze/hongze_task/models/data_manage"
  7. "hongze/hongze_task/models/roadshow"
  8. "hongze/hongze_task/models/yb"
  9. "hongze/hongze_task/utils"
  10. "time"
  11. "github.com/beego/beego/v2/client/orm"
  12. )
  13. func init() {
  14. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  15. orm.SetMaxIdleConns("default", 50)
  16. orm.SetMaxOpenConns("default", 100)
  17. db, _ := orm.GetDB("default")
  18. db.SetConnMaxLifetime(10 * time.Minute)
  19. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  20. orm.SetMaxIdleConns("rddp", 50)
  21. orm.SetMaxOpenConns("rddp", 100)
  22. report_db, _ := orm.GetDB("rddp")
  23. report_db.SetConnMaxLifetime(10 * time.Minute)
  24. _ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB)
  25. orm.SetMaxIdleConns("edb", 50)
  26. orm.SetMaxOpenConns("edb", 100)
  27. edb_db, _ := orm.GetDB("edb")
  28. edb_db.SetConnMaxLifetime(10 * time.Minute)
  29. _ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA)
  30. orm.SetMaxIdleConns("data", 50)
  31. orm.SetMaxOpenConns("data", 100)
  32. data_db, _ := orm.GetDB("data")
  33. data_db.SetConnMaxLifetime(10 * time.Minute)
  34. _ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
  35. orm.SetMaxIdleConns("gl", 50)
  36. orm.SetMaxOpenConns("gl", 100)
  37. gl, _ := orm.GetDB("gl")
  38. gl.SetConnMaxLifetime(10 * time.Minute)
  39. //注册对象
  40. orm.RegisterModel(
  41. new(EdbinfoSendMsgRecord),
  42. new(StackCompanyStatistic),
  43. new(company_contract.CompanyContract),
  44. new(company_contract.CompanyContractPermission),
  45. new(company_approval.CompanyApproval),
  46. new(Classify),
  47. new(ReportSendThsDetail),
  48. new(Report),
  49. new(UserViewStatistics),
  50. new(roadshow.RsReportRecord), //路演记录
  51. new(CompanyReportRecord),
  52. )
  53. // 注册客户信息 数据表
  54. initCompany()
  55. // 注册Edb指标 数据表
  56. initEdbDataTable()
  57. // 注册ETA表格 数据表
  58. initYbTable()
  59. }
  60. // initCompany 注册客户信息 数据表
  61. func initCompany() {
  62. //注册对象
  63. orm.RegisterModel(
  64. new(Company),
  65. new(CompanyReportPermission),
  66. new(CompanyReportPermissionLog),
  67. new(CompanyOperationRecord),
  68. new(CompanyProduct),
  69. new(CompanyPermissionLog),
  70. new(CompanyEndDate),
  71. new(CompanyProductUpdateLog), //客户产品状态变更表
  72. new(CompanyViewStatistics),
  73. )
  74. }
  75. // initEdbDataTable 注册Edb指标 数据表
  76. func initEdbDataTable() {
  77. //注册对象
  78. orm.RegisterModel(
  79. new(DataSourceLongzhong),
  80. new(Longzhonginfo),
  81. new(Longzhongdata),
  82. new(EdbdataClassify),
  83. new(Longzhongpriceinfo),
  84. new(Longzhongpricedata),
  85. new(LongzhongSurveyProduct),
  86. new(LongzhongSurveyData),
  87. new(data_manage.EdbDataWind),
  88. new(data_manage.EdbDataThs),
  89. new(data_manage.EdbDataPb),
  90. new(data_manage.BaseFromSmm),
  91. new(data_manage.BaseFromSmmIndex),
  92. new(data_manage.BaseFromSmmData),
  93. new(data_manage.EdbDataYs),
  94. new(Edbdata),
  95. new(data_manage.EdbInfoCalculateMapping),
  96. new(data_manage.EdbInfo), //hz_data库的edb_info表
  97. new(data_manage.EdbDataCalculateZjpj), //直接拼接
  98. new(data_manage.EdbDataCalculateLjztbpj), //累计同比值拼接
  99. new(data_manage.EdbDataLt), //路透指标数据表
  100. )
  101. }
  102. // initYbTable 注册ETA表格 数据表
  103. func initYbTable() {
  104. //注册对象
  105. orm.RegisterModel(
  106. new(yb.Activity), // 研报活动表
  107. new(yb.ActivityType), //研报活动分类表
  108. new(yb.ActivityVoice), //研报活动语音表
  109. new(yb.ActivityRegister), //研报活动报名表
  110. new(yb.Speaker), //研报主持人表
  111. )
  112. }