db.go 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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.RegisterDataBase("eta", "mysql", utils.MYSQL_URL_ETA)
  47. orm.SetMaxIdleConns("eta", 50)
  48. orm.SetMaxOpenConns("eta", 100)
  49. etaDb, _ := orm.GetDB("eta")
  50. etaDb.SetConnMaxLifetime(10 * time.Minute)
  51. orm.Debug = true
  52. orm.DebugLog = orm.NewLog(utils.Binlog)
  53. //注册对象
  54. orm.RegisterModel(
  55. new(EdbinfoSendMsgRecord),
  56. new(StackCompanyStatistic),
  57. new(company_contract.CompanyContract),
  58. new(company_contract.CompanyContractPermission),
  59. new(company_approval.CompanyApproval),
  60. new(Classify),
  61. new(ReportSendThsDetail),
  62. new(Report),
  63. new(UserViewStatistics),
  64. new(roadshow.RsReportRecord), //路演记录
  65. new(CompanyReportRecord),
  66. new(ChartPermission), // 权限表
  67. )
  68. // 注册客户信息 数据表
  69. initCompany()
  70. // 注册Edb指标 数据表
  71. initEdbDataTable()
  72. // 注册研报 数据表
  73. initYbTable()
  74. // 注册查研观向 数据表
  75. initCygx()
  76. // 注册商品期货 相关数据表
  77. initFutureGoodEdbDataTable()
  78. //注册持仓分析 数据表
  79. initTradePositionTop()
  80. // ETA商家数据表
  81. initEtaBusiness()
  82. //英文研报
  83. initEnglishReport()
  84. // ETA商家配置表
  85. initEtaBusinessConf()
  86. }
  87. // initCompany 注册客户信息 数据表
  88. func initCompany() {
  89. //注册对象
  90. orm.RegisterModel(
  91. new(Company),
  92. new(CompanyReportPermission),
  93. new(CompanyReportPermissionLog),
  94. new(CompanyOperationRecord),
  95. new(CompanyProduct),
  96. new(CompanyPermissionLog),
  97. new(CompanyEndDate),
  98. new(CompanyProductUpdateLog), //客户产品状态变更表
  99. new(CompanyViewStatistics),
  100. new(CompanyRemindRecord), // 客户提醒记录
  101. )
  102. }
  103. // initEdbDataTable 注册Edb指标 数据表
  104. func initEdbDataTable() {
  105. //注册对象
  106. orm.RegisterModel(
  107. new(DataSourceLongzhong),
  108. new(Longzhonginfo),
  109. new(Longzhongdata),
  110. new(EdbdataClassify),
  111. new(Longzhongpriceinfo),
  112. new(Longzhongpricedata),
  113. new(LongzhongSurveyProduct),
  114. new(LongzhongSurveyData),
  115. new(data_manage.EdbDataWind),
  116. new(data_manage.EdbDataThs),
  117. new(data_manage.EdbDataPb),
  118. new(data_manage.BaseFromSmm),
  119. new(data_manage.BaseFromSmmIndex),
  120. new(data_manage.BaseFromSmmData),
  121. new(data_manage.EdbDataYs),
  122. new(Edbdata),
  123. new(data_manage.EdbInfoCalculateMapping),
  124. new(data_manage.EdbInfo), //hz_data库的edb_info表
  125. new(data_manage.EdbDataCalculateZjpj), //直接拼接
  126. new(data_manage.EdbDataCalculateLjztbpj), //累计同比值拼接
  127. new(data_manage.EdbDataLt), //路透指标数据表
  128. new(VarietyClassify), // 标签分类表
  129. new(VarietyTag), // 标签表
  130. new(ResearchVarietyTagRelation), // 研究员标签关系表
  131. new(CompanyProductTryOutUpdateLog), //客户产品试用变更状态表
  132. new(CompanyProductTryOutUpdatePermissionLog), //客户产品试用变更品种详情表
  133. )
  134. }
  135. // initYbTable 注册ETA表格 数据表
  136. func initYbTable() {
  137. //注册对象
  138. orm.RegisterModel(
  139. new(yb.Activity), // 研报活动表
  140. new(yb.ActivityType), //研报活动分类表
  141. new(yb.ActivityVoice), //研报活动语音表
  142. new(yb.ActivityRegister), //研报活动报名表
  143. new(yb.Speaker), //研报主持人表
  144. new(yb.PriceDriven), // 研报价格驱动表
  145. new(yb.ComeinEvent), //进门会议表
  146. new(yb.ComeinEventUser), //进门会议用户表
  147. new(yb.CommunityVideo), //研报视频社区
  148. new(yb.VoiceBroadcast), // 语音播报
  149. )
  150. }
  151. // initCygx 注册查研观向 数据表
  152. func initCygx() {
  153. //注册对象
  154. orm.RegisterModel(
  155. new(data_manage.CygxReportMapping),
  156. new(data_manage.CygxResearchSummary),
  157. new(data_manage.CygxResearchSummaryLog),
  158. new(data_manage.CygxMinutesSummary),
  159. new(data_manage.CygxMinutesSummaryLog),
  160. new(data_manage.CygxArticle),
  161. new(data_manage.CygxArticleType),
  162. new(data_manage.CygxActivitySpecialTripBill),
  163. new(data_manage.CygxActivitySpecialInheritPointsCompany),
  164. )
  165. }
  166. // initFutureGoodEdbDataTable 注册商品期货Edb指标 数据表
  167. func initFutureGoodEdbDataTable() {
  168. //注册对象
  169. orm.RegisterModel(
  170. new(future_good.FutureGoodEdbInfo),
  171. )
  172. }
  173. // initTradePositionTop 注册持仓分析 数据表
  174. func initTradePositionTop() {
  175. //注册对象
  176. orm.RegisterModel(
  177. new(data_manage.TradePositionDalianTop),
  178. new(data_manage.TradePositionZhengzhouTop),
  179. new(data_manage.TradePositionShanghaiTop),
  180. new(data_manage.TradePositionIneTop),
  181. new(data_manage.TradePositionCffexTop),
  182. new(data_manage.BaseFromTradeClassify), // 交易所分类
  183. )
  184. }
  185. // initEtaBusiness ETA商家数据表
  186. func initEtaBusiness() {
  187. orm.RegisterModel(
  188. new(eta_business.EtaBusiness),
  189. new(eta_business.EtaBusinessContract),
  190. new(eta_business.EtaBusinessRemindRecord),
  191. )
  192. }
  193. // initEtaBusinessConf ETA商家基本配置表
  194. func initEtaBusinessConf() {
  195. orm.RegisterModel(
  196. new(BusinessConf),
  197. )
  198. }
  199. // initEnglishReport 英文研报
  200. func initEnglishReport() {
  201. orm.RegisterModel(
  202. new(EnglishReport),
  203. )
  204. }