db.go 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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(CygxReportSelectionSubjectHistory),
  136. new(CygxTacticsTimeLineHistory),
  137. new(CygxActivitySignin),
  138. new(CygxActivitySigninLog),
  139. new(CygxActivityOfflineMeetingDetail),
  140. new(CygxProductInteriorHistory),
  141. new(CygxMorningMeetingGather),
  142. new(CygxArticleCategoryMapping),
  143. new(CygxReportMappingCygx),
  144. new(CygxReportMappingGroup),
  145. new(CygxAboutUsVideoHistory),
  146. new(CygxActivitySignupBreak),
  147. new(CygxBannerHistory),
  148. new(CygxReportHistoryRecordLog),
  149. new(CygxUserLabel),
  150. new(CygxUserLabelActivity),
  151. new(CygxUserLabelArticle),
  152. new(CygxUserLabelActivitySpecial),
  153. new(CygxInviteCompany),
  154. new(CygxActivityPointsBill),
  155. new(CygxActivityPointsCompany),
  156. new(CygxTagHistory),
  157. new(CygxReportMappingCategoryGroup),
  158. new(CygxActivitySpecialInheritPointsCompany),
  159. new(CygxApplyCollection),
  160. new(CygxArticleApplyAppointmentExpert),
  161. new(CygxBannerYxSurvey),
  162. new(CygxReportSelectionLogApply),
  163. new(CygxResourceDataIndustrialGroupManagement),
  164. new(CygxResourceDataIndustrialGroupSubject),
  165. new(CygxIndustryFllowLog),
  166. new(CygxYanxuanSpecialRecord),
  167. new(CygxYanxuanSpecialRecordLog),
  168. new(CygxYanxuanSpecialCollect),
  169. new(CygxYanxuanSpecial),
  170. new(CygxYanxuanSpecialFollow),
  171. new(CygxYanxuanSpecialCompany),
  172. new(CygxYanxuanSpecialApprovalLog),
  173. new(CygxQuestionnaireVote),
  174. new(CygxQuestionnaireVoteOtherTheme),
  175. new(CygxMorningMeetingReviewChapterHistory),
  176. new(CygxAskserieVideoHistoryRecord),
  177. new(CygxAskserieVideoCollection),
  178. new(CygxAskserieVideoCollect),
  179. new(CygxVoiceAndVideoHistory),
  180. new(CygxArticleAndYanxuanRecord),
  181. new(CygxTimelineLog),
  182. new(CygxActivitySpecialPermissionPoints),
  183. new(time_line.CygxGushouTimeLineHistory),
  184. )
  185. initOrder() // 订单模块
  186. initRaiServe() // 权益服务记录模块
  187. initFiccReport() // 权益服务记录模块
  188. initYidong() // 易董初始化数据模块
  189. // 记录ORM查询日志
  190. orm.Debug = true
  191. orm.DebugLog = orm.NewLog(utils.Binlog)
  192. }
  193. // initOrder 买方研选订单模块
  194. func initOrder() {
  195. orm.RegisterModel(
  196. new(order.CygxOrder), //订单表
  197. new(order.CygxOrderAction), //订单操表
  198. new(order.CygxOrderUserCard), //用户持卡表
  199. new(order.CygxOrderUserCardLog), //用户持卡日志表
  200. new(order.CygxOrderPayment), //支付记录表
  201. new(order.CygxOrderVirtualAsset), //用户虚拟资产表(所购买的单篇报告,活动等)
  202. )
  203. }
  204. // 权益服务记录模块
  205. func initRaiServe() {
  206. orm.RegisterModel(
  207. new(rai_serve.CygxRaiServeBill), //服务明细表
  208. new(rai_serve.CygxRaiServeCompany), //当前所属权益服务公司表
  209. new(rai_serve.CygxRaiServeWeekBill), //当前所属权益服务公司周度统计表
  210. new(rai_serve.CygxRaiCompanyUserBill), //权益正式,试用客户近四周互动记录统计表
  211. )
  212. }
  213. // ficc研报
  214. func initFiccReport() {
  215. orm.RegisterModel(
  216. new(ficc_report.FiccYbXcxHistory), //ficc研报小程序点击记录
  217. )
  218. }
  219. // initYidong
  220. func initYidong() {
  221. orm.RegisterModel(
  222. new(yidong.CygxYidongActivity), //易董活动原始数据
  223. new(yidong.CygxYidongActivityMeetData), //易董活动到会信息原始数据
  224. )
  225. }