db.go 6.9 KB

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