db.go 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. "hongze/hongze_mfyx/models/order"
  5. "hongze/hongze_mfyx/utils"
  6. "time"
  7. "github.com/beego/beego/v2/client/orm"
  8. )
  9. func init() {
  10. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_CYGX)
  11. orm.SetMaxIdleConns("default", 50)
  12. orm.SetMaxOpenConns("default", 100)
  13. cygx_db, _ := orm.GetDB("default")
  14. cygx_db.SetConnMaxLifetime(10 * time.Minute)
  15. _ = orm.RegisterDataBase("weekly_report", "mysql", utils.MYSQL_URL)
  16. orm.SetMaxIdleConns("weekly_report", 50)
  17. orm.SetMaxOpenConns("weekly_report", 100)
  18. db, _ := orm.GetDB("weekly_report")
  19. db.SetConnMaxLifetime(10 * time.Minute)
  20. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  21. orm.SetMaxIdleConns("rddp", 50)
  22. orm.SetMaxOpenConns("rddp", 100)
  23. report_db, _ := orm.GetDB("rddp")
  24. report_db.SetConnMaxLifetime(10 * time.Minute)
  25. //orm.RegisterDataBase("tactics", "mysql", utils.MYSQL_URL_TACTICS)
  26. //orm.SetMaxIdleConns("tactics", 50)
  27. //orm.SetMaxOpenConns("tactics", 100)
  28. //
  29. //tacticsDb, _ := orm.GetDB("tactics")
  30. //tacticsDb.SetConnMaxLifetime(10 * time.Minute)
  31. //
  32. //orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
  33. //orm.SetMaxIdleConns("comein_data", 50)
  34. //orm.SetMaxOpenConns("comein_data", 100)
  35. //
  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(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(CygxActivitySpecialMeetingDetail),
  97. new(CygxUserFollowSpecial),
  98. new(CygxArticleHistoryRecordAll),
  99. new(CygxActivityAppointment),
  100. new(UserTemplateRecord),
  101. new(CygxUserInteractionNum),
  102. new(CygxCompanyInteractionNum),
  103. new(CygxSessionMobile),
  104. new(CygxSearchKeyWordLog),
  105. new(CygxActivity),
  106. new(CygxIndustrialActivityGroupManagement),
  107. new(CygxIndustrialActivityGroupSubject),
  108. new(CygxActivityVoiceHistory),
  109. new(CygxThreeApiLog),
  110. new(CygxIndustrialArticleGroupManagement),
  111. new(ArticleTopHistoryRecord),
  112. new(CygxActivitySignupDetail),
  113. new(CygxMicroRoadshowVideoHistory),
  114. new(MicroRoadshowVideo),
  115. new(CygxActivityVideoHistory),
  116. new(CygxActivitySpecialTrip),
  117. new(CygxArticleComment),
  118. new(CygxResourceData),
  119. new(CygxResearchSummaryVoiceHistory),
  120. new(CygxMinutesSummaryVoiceHistory),
  121. new(CygxReportSelectionVoiceHistory),
  122. new(CygxActivitySpecialTripBill),
  123. new(CygxXzsChooseCategory),
  124. new(CygxReportSelectionSubjectHistory),
  125. new(CygxTacticsTimeLineHistory),
  126. new(CygxProductInteriorHistory),
  127. new(CygxMorningMeetingGather),
  128. new(CygxArticleCategoryMapping),
  129. new(CygxReportMappingCygx),
  130. new(CygxReportMappingGroup),
  131. new(CygxActivitySignin),
  132. new(CygxActivitySigninLog),
  133. new(CygxActivityOfflineMeetingDetail),
  134. new(CygxBannerHistory),
  135. new(CygxActivitySignupBreak),
  136. new(CygxReportHistoryRecordLog),
  137. new(CygxUserLabel),
  138. new(CygxUserLabelActivity),
  139. new(CygxUserLabelArticle),
  140. new(CygxUserLabelActivitySpecial),
  141. new(CygxInviteCompany),
  142. new(CygxActivityPointsBill),
  143. new(CygxActivityPointsCompany),
  144. new(CygxTagHistory),
  145. new(CygxReportMappingCategoryGroup),
  146. new(CygxActivitySpecialInheritPointsCompany),
  147. new(CygxApplyCollection),
  148. new(CygxArticleApplyAppointmentExpert),
  149. new(CygxBannerYxSurvey),
  150. new(CygxReportSelectionLogApply),
  151. new(CygxResourceDataIndustrialGroupManagement),
  152. new(CygxResourceDataIndustrialGroupSubject),
  153. new(CygxIndustryFllowLog),
  154. new(CygxYanxuanSpecialRecord),
  155. new(CygxYanxuanSpecialRecordLog),
  156. new(CygxYanxuanSpecialCollect),
  157. new(CygxYanxuanSpecial),
  158. new(CygxYanxuanSpecialFollow),
  159. new(CygxYanxuanSpecialCompany),
  160. new(CygxYanxuanSpecialApprovalLog),
  161. new(CygxYanxuanSpecialMessage),
  162. new(CygxYanxuanSpecialMessageLike),
  163. new(CygxYanxuanSpecialSpecialLike),
  164. new(CygxQuestionnaireVote),
  165. new(CygxQuestionnaireVoteOtherTheme),
  166. new(CygxMorningMeetingReviewChapterHistory),
  167. new(CygxAskserieVideoHistoryRecord),
  168. new(CygxAskserieVideoCollection),
  169. new(CygxAskserieVideoCollect),
  170. new(CygxVoiceAndVideoHistory),
  171. new(CygxArticleAndYanxuanRecord),
  172. new(CygxUserAdminShareHistory),
  173. new(CygxUserAdminShareCode),
  174. new(AliyunOcrLog),
  175. new(CygxActivityVivoPointRecord),
  176. )
  177. initOrder() // 订单模块
  178. // 记录ORM查询日志
  179. orm.Debug = true
  180. orm.DebugLog = orm.NewLog(utils.Binlog)
  181. }
  182. // initOrder 买方研选订单模块
  183. func initOrder() {
  184. orm.RegisterModel(
  185. new(order.CygxUserBusinessCard), //用户上传名片
  186. new(order.CygxOrder), //订单表
  187. new(order.CygxOrderAction), //订单操表
  188. new(order.CygxOrderUserCard), //用户持卡表
  189. new(order.CygxOrderUserCardLog), //用户持卡日志表
  190. new(order.CygxOrderPayment), //支付记录表
  191. new(order.CygxOrderVirtualAsset), //用户虚拟资产表(所购买的单篇报告,活动等)
  192. )
  193. }