db.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. "hongze/hongze_cygx/utils"
  5. "time"
  6. "github.com/beego/beego/v2/client/orm"
  7. )
  8. func init() {
  9. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_CYGX)
  10. orm.SetMaxIdleConns("default", 50)
  11. orm.SetMaxOpenConns("default", 100)
  12. cygx_db, _ := orm.GetDB("default")
  13. cygx_db.SetConnMaxLifetime(10 * time.Minute)
  14. _ = orm.RegisterDataBase("weekly_report", "mysql", utils.MYSQL_URL)
  15. orm.SetMaxIdleConns("weekly_report", 50)
  16. orm.SetMaxOpenConns("weekly_report", 100)
  17. db, _ := orm.GetDB("weekly_report")
  18. db.SetConnMaxLifetime(10 * time.Minute)
  19. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  20. orm.SetMaxIdleConns("rddp", 50)
  21. orm.SetMaxOpenConns("rddp", 100)
  22. report_db, _ := orm.GetDB("rddp")
  23. report_db.SetConnMaxLifetime(10 * time.Minute)
  24. orm.RegisterDataBase("tactics", "mysql", utils.MYSQL_URL_TACTICS)
  25. orm.SetMaxIdleConns("tactics", 50)
  26. orm.SetMaxOpenConns("tactics", 100)
  27. tacticsDb, _ := orm.GetDB("tactics")
  28. tacticsDb.SetConnMaxLifetime(10 * time.Minute)
  29. orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
  30. orm.SetMaxIdleConns("comein_data", 50)
  31. orm.SetMaxOpenConns("comein_data", 100)
  32. comein_datadb, _ := orm.GetDB("comein_data")
  33. comein_datadb.SetConnMaxLifetime(10 * time.Minute)
  34. //
  35. //orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
  36. //orm.SetMaxIdleConns("comein_data", 50)
  37. //orm.SetMaxOpenConns("comein_data", 100)
  38. //
  39. //comein_dataDb, _ := orm.GetDB("comein_data")
  40. //comein_dataDb.SetConnMaxLifetime(10 * time.Minute)
  41. //注册对象
  42. orm.RegisterModel(
  43. new(WxUser),
  44. new(CygxSession),
  45. new(WxUserLog),
  46. new(WxUserCode),
  47. new(CygxArticleCollect),
  48. new(CygxArticleViewRecord),
  49. new(CygxAdvice),
  50. new(MsgCode),
  51. new(Resource),
  52. new(CygxApplyRecord),
  53. new(CygxInterviewApply),
  54. new(CygxArticle),
  55. new(CygxArticleHistoryRecord),
  56. new(CygxSearchKeyWord),
  57. new(UserRecord),
  58. new(CygxIndustryTop),
  59. new(CygxActivitySignup),
  60. new(CygxActivitySignupLog),
  61. new(CygxActivityUserSearchContent),
  62. new(CygxActivityMeetingReminder),
  63. new(CygxActivityMeetingReminderLog),
  64. new(CygxMySchedule),
  65. new(WxUserWhite),
  66. new(CygxActivityHelpAsk),
  67. new(CygxIndustryFllow),
  68. new(CygxArticleDepartmentFollow),
  69. new(CygxArticleAsk),
  70. new(CygxPageHistoryRecord),
  71. new(CygxReportHistoryRecord),
  72. new(CygxArticleAuthor),
  73. new(CygxUserRecord),
  74. new(CygxReportIndustrialSeaarchHistory),
  75. new(CygxArticleHistoryRecordNewpv),
  76. new(CygxActivitySearchHistory),
  77. new(CygxActivityAttendanceDetail),
  78. new(CygxActivityRestrictSignup),
  79. new(CygxActivityMeetDetailLog),
  80. new(CygxUserSearchKeyWord),
  81. new(CompanyReportPermission),
  82. new(Company),
  83. new(CompanyLog),
  84. new(CompanyOperationRecord),
  85. new(CompanyPermissionLog),
  86. new(CompanyProduct),
  87. new(CompanyProductLog),
  88. new(UserSellerRelation),
  89. new(CygxShanghaiCompanyLog),
  90. new(CygxShanghaiErrLog),
  91. new(CygxUserFreeeButton),
  92. new(UserInvitee),
  93. new(CygxActivitySpecialSignup),
  94. new(CygxActivitySpecialMeetingDetail),
  95. new(CygxUserFollowSpecial),
  96. new(CygxChart),
  97. new(CygxChartCollect),
  98. new(CygxChartTop),
  99. new(CygxCelueArticleHistoryRecord),
  100. new(CygxArticleHistoryRecordAll),
  101. new(CygxActivityAppointment),
  102. new(UserTemplateRecord),
  103. new(CygxUserInteractionNum),
  104. new(CygxChartCollectByCygx),
  105. new(CygxCompanyInteractionNum),
  106. new(CygxChartAll),
  107. new(CygxSessionMobile),
  108. new(CygxSearchKeyWordLog),
  109. new(CygxActivity),
  110. new(CygxYidongActivityMeetingApiLog),
  111. new(CygxIndustrialActivityGroupManagement),
  112. new(CygxIndustrialActivityGroupSubject),
  113. new(CygxActivityVoiceHistory),
  114. new(CygxThreeApiLog),
  115. new(CygxIndustrialArticleGroupManagement),
  116. new(ArticleTopHistoryRecord),
  117. new(CygxActivitySignupDetail),
  118. new(CygxMicroRoadshowVideoHistory),
  119. new(MicroRoadshowVideo),
  120. new(CygxActivityVideoHistory),
  121. new(CygxActivitySpecialTrip),
  122. new(CygxArticleData),
  123. new(CygxArticleComment),
  124. new(CygxResourceData),
  125. new(CygxResearchSummaryVoiceHistory),
  126. new(CygxMinutesSummaryVoiceHistory),
  127. new(CygxReportSelectionVoiceHistory),
  128. new(CygxActivitySpecialTripBill),
  129. new(CygxXzsChooseCategory),
  130. new(CygxReportSelectionSubjectHistory),
  131. new(CygxTacticsTimeLineHistory),
  132. new(CygxActivitySignin),
  133. new(CygxActivitySigninLog),
  134. new(CygxActivityOfflineMeetingDetail),
  135. new(CygxProductInteriorHistory),
  136. new(CygxMorningMeetingGather),
  137. new(CygxArticleCategoryMapping),
  138. new(CygxReportMappingCygx),
  139. new(CygxReportMappingGroup),
  140. new(CygxAboutUsVideoHistory),
  141. new(CygxActivitySignupBreak),
  142. new(CygxBannerHistory),
  143. new(CygxReportHistoryRecordLog),
  144. new(CygxUserLabel),
  145. new(CygxUserLabelActivity),
  146. new(CygxUserLabelArticle),
  147. new(CygxUserLabelActivitySpecial),
  148. new(CygxInviteCompany),
  149. new(CygxActivityPointsBill),
  150. new(CygxActivityPointsCompany),
  151. new(CygxTagHistory),
  152. new(CygxReportMappingCategoryGroup),
  153. new(CygxActivitySpecialInheritPointsCompany),
  154. new(CygxApplyCollection),
  155. new(CygxArticleApplyAppointmentExpert),
  156. new(CygxBannerYxSurvey),
  157. new(CygxReportSelectionLogApply),
  158. new(CygxResourceDataIndustrialGroupManagement),
  159. new(CygxResourceDataIndustrialGroupSubject),
  160. new(CygxIndustryFllowLog),
  161. new(CygxYanxuanSpecialRecord),
  162. new(CygxYanxuanSpecialCollect),
  163. new(CygxYanxuanSpecial),
  164. new(CygxYanxuanSpecialFollow),
  165. new(CygxYanxuanSpecialCompany),
  166. new(CygxQuestionnaireVote),
  167. new(CygxQuestionnaireVoteOtherTheme),
  168. new(CygxMorningMeetingReviewChapterHistory),
  169. new(CygxAskserieVideoHistoryRecord),
  170. new(CygxAskserieVideoCollection),
  171. new(CygxAskserieVideoCollect),
  172. new(CygxVoiceAndVideoHistory),
  173. )
  174. // 记录ORM查询日志
  175. orm.Debug = true
  176. orm.DebugLog = orm.NewLog(utils.BinLog)
  177. }