db.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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(CygxArticleData),
  118. new(CygxArticleComment),
  119. new(CygxResourceData),
  120. new(CygxResearchSummaryVoiceHistory),
  121. new(CygxMinutesSummaryVoiceHistory),
  122. new(CygxReportSelectionVoiceHistory),
  123. new(CygxActivitySpecialTripBill),
  124. new(CygxXzsChooseCategory),
  125. new(CygxReportSelectionSubjectHistory),
  126. new(CygxTacticsTimeLineHistory),
  127. new(CygxProductInteriorHistory),
  128. new(CygxMorningMeetingGather),
  129. new(CygxArticleCategoryMapping),
  130. new(CygxReportMappingCygx),
  131. new(CygxReportMappingGroup),
  132. new(CygxActivitySignin),
  133. new(CygxActivitySigninLog),
  134. new(CygxActivityOfflineMeetingDetail),
  135. new(CygxBannerHistory),
  136. new(CygxActivitySignupBreak),
  137. new(CygxReportHistoryRecordLog),
  138. new(CygxUserLabel),
  139. new(CygxUserLabelActivity),
  140. new(CygxUserLabelArticle),
  141. new(CygxUserLabelActivitySpecial),
  142. new(CygxInviteCompany),
  143. new(CygxActivityPointsBill),
  144. new(CygxActivityPointsCompany),
  145. new(CygxTagHistory),
  146. new(CygxReportMappingCategoryGroup),
  147. new(CygxActivitySpecialInheritPointsCompany),
  148. new(CygxApplyCollection),
  149. new(CygxArticleApplyAppointmentExpert),
  150. new(CygxBannerYxSurvey),
  151. new(CygxReportSelectionLogApply),
  152. new(CygxResourceDataIndustrialGroupManagement),
  153. new(CygxResourceDataIndustrialGroupSubject),
  154. new(CygxIndustryFllowLog),
  155. new(CygxYanxuanSpecialRecord),
  156. new(CygxYanxuanSpecialRecordLog),
  157. new(CygxYanxuanSpecialCollect),
  158. new(CygxYanxuanSpecial),
  159. new(CygxYanxuanSpecialFollow),
  160. new(CygxYanxuanSpecialCompany),
  161. new(CygxYanxuanSpecialApprovalLog),
  162. new(CygxQuestionnaireVote),
  163. new(CygxQuestionnaireVoteOtherTheme),
  164. new(CygxMorningMeetingReviewChapterHistory),
  165. new(CygxAskserieVideoHistoryRecord),
  166. new(CygxAskserieVideoCollection),
  167. new(CygxAskserieVideoCollect),
  168. new(CygxVoiceAndVideoHistory),
  169. new(CygxArticleAndYanxuanRecord),
  170. )
  171. initOrder() // 订单模块
  172. // 记录ORM查询日志
  173. orm.Debug = true
  174. orm.DebugLog = orm.NewLog(utils.BinLog)
  175. }
  176. // initOrder 买方研选订单模块
  177. func initOrder() {
  178. orm.RegisterModel(
  179. new(order.CygxUserBusinessCard), //用户上传名片
  180. )
  181. }