db.go 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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/data_manage/future_good"
  8. "hongze/hongze_task/models/eta_business"
  9. "hongze/hongze_task/models/roadshow"
  10. "hongze/hongze_task/models/yb"
  11. "hongze/hongze_task/utils"
  12. "time"
  13. "github.com/beego/beego/v2/client/orm"
  14. )
  15. func init() {
  16. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  17. orm.SetMaxIdleConns("default", 50)
  18. orm.SetMaxOpenConns("default", 100)
  19. db, _ := orm.GetDB("default")
  20. db.SetConnMaxLifetime(10 * time.Minute)
  21. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  22. orm.SetMaxIdleConns("rddp", 50)
  23. orm.SetMaxOpenConns("rddp", 100)
  24. report_db, _ := orm.GetDB("rddp")
  25. report_db.SetConnMaxLifetime(10 * time.Minute)
  26. _ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB)
  27. orm.SetMaxIdleConns("edb", 50)
  28. orm.SetMaxOpenConns("edb", 100)
  29. edb_db, _ := orm.GetDB("edb")
  30. edb_db.SetConnMaxLifetime(10 * time.Minute)
  31. _ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA)
  32. orm.SetMaxIdleConns("data", 50)
  33. orm.SetMaxOpenConns("data", 100)
  34. data_db, _ := orm.GetDB("data")
  35. data_db.SetConnMaxLifetime(10 * time.Minute)
  36. _ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
  37. orm.SetMaxIdleConns("gl", 50)
  38. orm.SetMaxOpenConns("gl", 100)
  39. gl, _ := orm.GetDB("gl")
  40. gl.SetConnMaxLifetime(10 * time.Minute)
  41. _ = orm.RegisterDataBase("weekly_trial", "mysql", utils.MYSQL_URL_WEEKLY_TRIAL)
  42. orm.SetMaxIdleConns("weekly_trial", 50)
  43. orm.SetMaxOpenConns("weekly_trial", 100)
  44. trial_datadb, _ := orm.GetDB("weekly_trial")
  45. trial_datadb.SetConnMaxLifetime(10 * time.Minute)
  46. orm.Debug = true
  47. orm.DebugLog = orm.NewLog(utils.Binlog)
  48. //注册对象
  49. orm.RegisterModel(
  50. new(EdbinfoSendMsgRecord),
  51. new(StackCompanyStatistic),
  52. new(company_contract.CompanyContract),
  53. new(company_contract.CompanyContractPermission),
  54. new(company_approval.CompanyApproval),
  55. new(Classify),
  56. new(ReportSendThsDetail),
  57. new(Report),
  58. new(UserViewStatistics),
  59. new(roadshow.RsReportRecord), //路演记录
  60. new(CompanyReportRecord),
  61. new(ChartPermission), // 权限表
  62. )
  63. // 注册客户信息 数据表
  64. initCompany()
  65. // 注册Edb指标 数据表
  66. initEdbDataTable()
  67. // 注册研报 数据表
  68. initYbTable()
  69. // 注册查研观向 数据表
  70. initCygx()
  71. // 注册商品期货 相关数据表
  72. initFutureGoodEdbDataTable()
  73. //注册持仓分析 数据表
  74. initTradePositionTop()
  75. // ETA商家数据表
  76. initEtaBusiness()
  77. }
  78. // initCompany 注册客户信息 数据表
  79. func initCompany() {
  80. //注册对象
  81. orm.RegisterModel(
  82. new(Company),
  83. new(CompanyReportPermission),
  84. new(CompanyReportPermissionLog),
  85. new(CompanyOperationRecord),
  86. new(CompanyProduct),
  87. new(CompanyPermissionLog),
  88. new(CompanyEndDate),
  89. new(CompanyProductUpdateLog), //客户产品状态变更表
  90. new(CompanyViewStatistics),
  91. new(CompanyRemindRecord), // 客户提醒记录
  92. )
  93. }
  94. // initEdbDataTable 注册Edb指标 数据表
  95. func initEdbDataTable() {
  96. //注册对象
  97. orm.RegisterModel(
  98. new(DataSourceLongzhong),
  99. new(Longzhonginfo),
  100. new(Longzhongdata),
  101. new(EdbdataClassify),
  102. new(Longzhongpriceinfo),
  103. new(Longzhongpricedata),
  104. new(LongzhongSurveyProduct),
  105. new(LongzhongSurveyData),
  106. new(data_manage.EdbDataWind),
  107. new(data_manage.EdbDataThs),
  108. new(data_manage.EdbDataPb),
  109. new(data_manage.BaseFromSmm),
  110. new(data_manage.BaseFromSmmIndex),
  111. new(data_manage.BaseFromSmmData),
  112. new(data_manage.EdbDataYs),
  113. new(Edbdata),
  114. new(data_manage.EdbInfoCalculateMapping),
  115. new(data_manage.EdbInfo), //hz_data库的edb_info表
  116. new(data_manage.EdbDataCalculateZjpj), //直接拼接
  117. new(data_manage.EdbDataCalculateLjztbpj), //累计同比值拼接
  118. new(data_manage.EdbDataLt), //路透指标数据表
  119. new(VarietyClassify), // 标签分类表
  120. new(VarietyTag), // 标签表
  121. new(ResearchVarietyTagRelation), // 研究员标签关系表
  122. new(CompanyProductTryOutUpdateLog), //客户产品试用变更状态表
  123. new(CompanyProductTryOutUpdatePermissionLog), //客户产品试用变更品种详情表
  124. )
  125. }
  126. // initYbTable 注册ETA表格 数据表
  127. func initYbTable() {
  128. //注册对象
  129. orm.RegisterModel(
  130. new(yb.Activity), // 研报活动表
  131. new(yb.ActivityType), //研报活动分类表
  132. new(yb.ActivityVoice), //研报活动语音表
  133. new(yb.ActivityRegister), //研报活动报名表
  134. new(yb.Speaker), //研报主持人表
  135. new(yb.PriceDriven), // 研报价格驱动表
  136. new(yb.ComeinEvent), //进门会议表
  137. new(yb.ComeinEventUser), //进门会议用户表
  138. new(yb.CommunityVideo), //研报视频社区
  139. new(yb.VoiceBroadcast), // 语音播报
  140. )
  141. }
  142. // initCygx 注册查研观向 数据表
  143. func initCygx() {
  144. //注册对象
  145. orm.RegisterModel(
  146. new(data_manage.CygxReportMapping),
  147. new(data_manage.CygxResearchSummary),
  148. new(data_manage.CygxResearchSummaryLog),
  149. new(data_manage.CygxMinutesSummary),
  150. new(data_manage.CygxMinutesSummaryLog),
  151. new(data_manage.CygxArticle),
  152. new(data_manage.CygxArticleType),
  153. )
  154. }
  155. // initFutureGoodEdbDataTable 注册商品期货Edb指标 数据表
  156. func initFutureGoodEdbDataTable() {
  157. //注册对象
  158. orm.RegisterModel(
  159. new(future_good.FutureGoodEdbInfo),
  160. )
  161. }
  162. // initTradePositionTop 注册持仓分析 数据表
  163. func initTradePositionTop() {
  164. //注册对象
  165. orm.RegisterModel(
  166. new(data_manage.TradePositionDalianTop),
  167. new(data_manage.TradePositionZhengzhouTop),
  168. new(data_manage.TradePositionShanghaiTop),
  169. new(data_manage.TradePositionIneTop),
  170. new(data_manage.TradePositionCffexTop),
  171. )
  172. }
  173. // initEtaBusiness ETA商家数据表
  174. func initEtaBusiness() {
  175. orm.RegisterModel(
  176. new(eta_business.EtaBusiness),
  177. new(eta_business.EtaBusinessContract),
  178. new(eta_business.EtaBusinessRemindRecord),
  179. )
  180. }