db.go 7.2 KB

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