db.go 7.5 KB

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