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