db.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. "hongze/hongze_mfyx/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. //
  28. //tacticsDb, _ := orm.GetDB("tactics")
  29. //tacticsDb.SetConnMaxLifetime(10 * time.Minute)
  30. //
  31. //orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
  32. //orm.SetMaxIdleConns("comein_data", 50)
  33. //orm.SetMaxOpenConns("comein_data", 100)
  34. //
  35. //comein_datadb, _ := orm.GetDB("comein_data")
  36. //comein_datadb.SetConnMaxLifetime(10 * time.Minute)
  37. //
  38. //orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
  39. //orm.SetMaxIdleConns("comein_data", 50)
  40. //orm.SetMaxOpenConns("comein_data", 100)
  41. //
  42. //comein_dataDb, _ := orm.GetDB("comein_data")
  43. //comein_dataDb.SetConnMaxLifetime(10 * time.Minute)
  44. //注册对象
  45. orm.RegisterModel(
  46. new(WxUser),
  47. new(CygxSession),
  48. new(WxUserLog),
  49. new(WxUserCode),
  50. new(CygxArticleCollect),
  51. new(CygxArticleViewRecord),
  52. new(CygxAdvice),
  53. new(MsgCode),
  54. new(Resource),
  55. new(CygxApplyRecord),
  56. new(CygxInterviewApply),
  57. new(CygxArticle),
  58. new(CygxArticleHistoryRecord),
  59. new(CygxSearchKeyWord),
  60. new(UserRecord),
  61. new(CygxIndustryTop),
  62. new(CygxActivitySignup),
  63. new(CygxActivitySignupLog),
  64. new(CygxActivityUserSearchContent),
  65. new(CygxActivityMeetingReminder),
  66. new(CygxActivityMeetingReminderLog),
  67. new(CygxMySchedule),
  68. new(WxUserWhite),
  69. new(CygxActivityHelpAsk),
  70. new(CygxIndustryFllow),
  71. new(CygxArticleDepartmentFollow),
  72. new(CygxArticleAsk),
  73. new(CygxPageHistoryRecord),
  74. new(CygxReportHistoryRecord),
  75. new(CygxArticleAuthor),
  76. new(CygxUserRecord),
  77. new(CygxReportIndustrialSeaarchHistory),
  78. new(CygxArticleHistoryRecordNewpv),
  79. new(CygxActivitySearchHistory),
  80. new(CygxActivityAttendanceDetail),
  81. new(CygxActivityRestrictSignup),
  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(CygxActivitySpecialMeetingDetail),
  96. new(CygxUserFollowSpecial),
  97. new(CygxArticleHistoryRecordAll),
  98. new(CygxActivityAppointment),
  99. new(UserTemplateRecord),
  100. new(CygxUserInteractionNum),
  101. new(CygxCompanyInteractionNum),
  102. new(CygxSessionMobile),
  103. new(CygxSearchKeyWordLog),
  104. new(CygxActivity),
  105. new(CygxIndustrialActivityGroupManagement),
  106. new(CygxIndustrialActivityGroupSubject),
  107. new(CygxActivityVoiceHistory),
  108. new(CygxThreeApiLog),
  109. new(CygxIndustrialArticleGroupManagement),
  110. new(ArticleTopHistoryRecord),
  111. new(CygxActivitySignupDetail),
  112. new(CygxMicroRoadshowVideoHistory),
  113. new(MicroRoadshowVideo),
  114. new(CygxActivityVideoHistory),
  115. new(CygxActivitySpecialTrip),
  116. new(CygxArticleData),
  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(CygxQuestionnaireVote),
  162. new(CygxQuestionnaireVoteOtherTheme),
  163. new(CygxMorningMeetingReviewChapterHistory),
  164. new(CygxAskserieVideoHistoryRecord),
  165. new(CygxAskserieVideoCollection),
  166. new(CygxAskserieVideoCollect),
  167. new(CygxVoiceAndVideoHistory),
  168. new(CygxArticleAndYanxuanRecord),
  169. new(CygxUserAdminShareHistory),
  170. new(CygxUserAdminShareCode),
  171. )
  172. // 记录ORM查询日志
  173. orm.Debug = true
  174. orm.DebugLog = orm.NewLog(utils.BinLog)
  175. }