db.go 6.7 KB

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