db.go 6.9 KB

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