db.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. _ "github.com/go-sql-driver/mysql"
  5. "hongze/hongze_cygx/models/ficc_report"
  6. "hongze/hongze_cygx/models/order"
  7. "hongze/hongze_cygx/models/rai_serve"
  8. "hongze/hongze_cygx/models/time_line"
  9. "hongze/hongze_cygx/models/yidong"
  10. "hongze/hongze_cygx/utils"
  11. "time"
  12. )
  13. func init() {
  14. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_CYGX)
  15. orm.SetMaxIdleConns("default", 50)
  16. orm.SetMaxOpenConns("default", 100)
  17. cygx_db, _ := orm.GetDB("default")
  18. cygx_db.SetConnMaxLifetime(10 * time.Minute)
  19. _ = orm.RegisterDataBase("weekly_report", "mysql", utils.MYSQL_URL)
  20. orm.SetMaxIdleConns("weekly_report", 50)
  21. orm.SetMaxOpenConns("weekly_report", 100)
  22. db, _ := orm.GetDB("weekly_report")
  23. db.SetConnMaxLifetime(10 * time.Minute)
  24. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  25. orm.SetMaxIdleConns("rddp", 50)
  26. orm.SetMaxOpenConns("rddp", 100)
  27. report_db, _ := orm.GetDB("rddp")
  28. report_db.SetConnMaxLifetime(10 * time.Minute)
  29. orm.RegisterDataBase("tactics", "mysql", utils.MYSQL_URL_TACTICS)
  30. orm.SetMaxIdleConns("tactics", 50)
  31. orm.SetMaxOpenConns("tactics", 100)
  32. tacticsDb, _ := orm.GetDB("tactics")
  33. tacticsDb.SetConnMaxLifetime(10 * time.Minute)
  34. orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
  35. orm.SetMaxIdleConns("comein_data", 50)
  36. orm.SetMaxOpenConns("comein_data", 100)
  37. comein_datadb, _ := orm.GetDB("comein_data")
  38. comein_datadb.SetConnMaxLifetime(10 * time.Minute)
  39. //
  40. //orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
  41. //orm.SetMaxIdleConns("comein_data", 50)
  42. //orm.SetMaxOpenConns("comein_data", 100)
  43. //
  44. //comein_dataDb, _ := orm.GetDB("comein_data")
  45. //comein_dataDb.SetConnMaxLifetime(10 * time.Minute)
  46. //注册对象
  47. orm.RegisterModel(
  48. new(WxUser),
  49. new(CygxSession),
  50. new(WxUserLog),
  51. new(WxUserCode),
  52. new(CygxArticleCollect),
  53. new(CygxArticleViewRecord),
  54. new(CygxAdvice),
  55. new(MsgCode),
  56. new(Resource),
  57. new(CygxApplyRecord),
  58. new(CygxInterviewApply),
  59. new(CygxArticle),
  60. new(CygxArticleHistoryRecord),
  61. new(CygxSearchKeyWord),
  62. new(UserRecord),
  63. new(CygxIndustryTop),
  64. new(CygxActivitySignup),
  65. new(CygxActivitySignupLog),
  66. new(CygxActivityUserSearchContent),
  67. new(CygxActivityMeetingReminder),
  68. new(CygxActivityMeetingReminderLog),
  69. new(CygxMySchedule),
  70. new(WxUserWhite),
  71. new(CygxActivityHelpAsk),
  72. new(CygxIndustryFllow),
  73. new(CygxArticleDepartmentFollow),
  74. new(CygxArticleAsk),
  75. new(CygxPageHistoryRecord),
  76. new(CygxReportHistoryRecord),
  77. new(CygxArticleAuthor),
  78. new(CygxUserRecord),
  79. new(CygxReportIndustrialSeaarchHistory),
  80. new(CygxArticleHistoryRecordNewpv),
  81. new(CygxActivitySearchHistory),
  82. new(CygxActivityAttendanceDetail),
  83. new(CygxActivityRestrictSignup),
  84. new(CygxActivityMeetDetailLog),
  85. new(CygxUserSearchKeyWord),
  86. new(CompanyReportPermission),
  87. new(Company),
  88. new(CompanyLog),
  89. new(CompanyOperationRecord),
  90. new(CompanyPermissionLog),
  91. new(CompanyProduct),
  92. new(CompanyProductLog),
  93. new(UserSellerRelation),
  94. new(CygxShanghaiCompanyLog),
  95. new(CygxShanghaiErrLog),
  96. new(CygxUserFreeeButton),
  97. new(UserInvitee),
  98. new(CygxActivitySpecialSignup),
  99. new(CygxActivitySpecialMeetingDetail),
  100. new(CygxUserFollowSpecial),
  101. new(CygxChart),
  102. new(CygxChartCollect),
  103. new(CygxChartTop),
  104. new(CygxCelueArticleHistoryRecord),
  105. new(CygxArticleHistoryRecordAll),
  106. new(CygxActivityAppointment),
  107. new(UserTemplateRecord),
  108. new(CygxUserInteractionNum),
  109. new(CygxChartCollectByCygx),
  110. new(CygxCompanyInteractionNum),
  111. new(CygxChartAll),
  112. new(CygxSessionMobile),
  113. new(CygxSearchKeyWordLog),
  114. new(CygxActivity),
  115. new(CygxYidongActivityMeetingApiLog),
  116. new(CygxIndustrialActivityGroupManagement),
  117. new(CygxIndustrialActivityGroupSubject),
  118. new(CygxActivityVoiceHistory),
  119. new(CygxThreeApiLog),
  120. new(CygxIndustrialArticleGroupManagement),
  121. new(ArticleTopHistoryRecord),
  122. new(CygxActivitySignupDetail),
  123. new(CygxMicroRoadshowVideoHistory),
  124. new(MicroRoadshowVideo),
  125. new(CygxActivityVideoHistory),
  126. new(CygxActivitySpecialTrip),
  127. new(CygxArticleData),
  128. new(CygxArticleComment),
  129. new(CygxResourceData),
  130. new(CygxResearchSummaryVoiceHistory),
  131. new(CygxMinutesSummaryVoiceHistory),
  132. new(CygxReportSelectionVoiceHistory),
  133. new(CygxActivitySpecialTripBill),
  134. new(CygxXzsChooseCategory),
  135. new(CygxXzsChooseCategoryZhouqi), //周期的关注系列
  136. new(CygxReportSelectionSubjectHistory),
  137. new(CygxTacticsTimeLineHistory),
  138. new(CygxProductInteriorHistory),
  139. new(CygxMorningMeetingGather),
  140. new(CygxArticleCategoryMapping),
  141. new(CygxReportMappingCygx),
  142. new(CygxReportMappingGroup),
  143. new(CygxAboutUsVideoHistory),
  144. new(CygxActivitySignin),
  145. new(CygxActivitySigninLog),
  146. new(CygxActivityOfflineMeetingDetail),
  147. new(CygxBannerHistory),
  148. new(CygxActivitySignupBreak),
  149. new(CygxReportHistoryRecordLog),
  150. new(CygxUserLabel),
  151. new(CygxUserLabelActivity),
  152. new(CygxUserLabelArticle),
  153. new(CygxUserLabelActivitySpecial),
  154. new(CygxInviteCompany),
  155. new(CygxActivityPointsBill),
  156. new(CygxActivityPointsCompany),
  157. new(CygxTagHistory),
  158. new(CygxReportMappingCategoryGroup),
  159. new(CygxActivitySpecialInheritPointsCompany),
  160. new(CygxApplyCollection),
  161. new(CygxArticleApplyAppointmentExpert),
  162. new(CygxBannerYxSurvey),
  163. new(CygxReportSelectionLogApply),
  164. new(CygxResourceDataIndustrialGroupManagement),
  165. new(CygxResourceDataIndustrialGroupSubject),
  166. new(CygxIndustryFllowLog),
  167. new(CygxYanxuanSpecialRecord),
  168. new(CygxYanxuanSpecialRecordLog),
  169. new(CygxYanxuanSpecialCollect),
  170. new(CygxYanxuanSpecial),
  171. new(CygxYanxuanSpecialFollow),
  172. new(CygxYanxuanSpecialCompany),
  173. new(CygxYanxuanSpecialApprovalLog),
  174. new(CygxQuestionnaireVote),
  175. new(CygxQuestionnaireVoteOtherTheme),
  176. new(CygxMorningMeetingReviewChapterHistory),
  177. new(CygxAskserieVideoHistoryRecord),
  178. new(CygxAskserieVideoCollection),
  179. new(CygxAskserieVideoCollect),
  180. new(CygxVoiceAndVideoHistory),
  181. new(CygxArticleAndYanxuanRecord),
  182. new(CygxTimelineLog),
  183. new(CygxActivitySpecialPermissionPoints),
  184. new(time_line.CygxGushouTimeLineHistory),
  185. new(CygxXzsChooseSend),
  186. )
  187. initOrder() // 订单模块
  188. initRaiServe() // 权益服务记录模块
  189. initFiccReport() // 权益服务记录模块
  190. initYidong() // 易董初始化数据模块
  191. // 记录ORM查询日志
  192. orm.Debug = true
  193. orm.DebugLog = orm.NewLog(utils.Binlog)
  194. }
  195. // initOrder 买方研选订单模块
  196. func initOrder() {
  197. orm.RegisterModel(
  198. new(order.CygxOrder), //订单表
  199. new(order.CygxOrderAction), //订单操表
  200. new(order.CygxOrderUserCard), //用户持卡表
  201. new(order.CygxOrderUserCardLog), //用户持卡日志表
  202. new(order.CygxOrderPayment), //支付记录表
  203. new(order.CygxOrderVirtualAsset), //用户虚拟资产表(所购买的单篇报告,活动等)
  204. )
  205. }
  206. // 权益服务记录模块
  207. func initRaiServe() {
  208. orm.RegisterModel(
  209. new(rai_serve.CygxRaiServeBill), //服务明细表
  210. new(rai_serve.CygxRaiServeCompany), //当前所属权益服务公司表
  211. new(rai_serve.CygxRaiServeWeekBill), //当前所属权益服务公司周度统计表
  212. new(rai_serve.CygxRaiCompanyUserBill), //权益正式,试用客户近四周互动记录统计表
  213. )
  214. }
  215. // ficc研报
  216. func initFiccReport() {
  217. orm.RegisterModel(
  218. new(ficc_report.FiccYbXcxHistory), //ficc研报小程序点击记录
  219. )
  220. }
  221. // initYidong
  222. func initYidong() {
  223. orm.RegisterModel(
  224. new(yidong.CygxYidongActivity), //易董活动原始数据
  225. new(yidong.CygxYidongActivityMeetData), //易董活动到会信息原始数据
  226. )
  227. }