db.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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)
  10. orm.SetMaxIdleConns("default", 50)
  11. orm.SetMaxOpenConns("default", 100)
  12. db, _ := orm.GetDB("default")
  13. db.SetConnMaxLifetime(10 * time.Minute)
  14. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  15. orm.SetMaxIdleConns("rddp", 50)
  16. orm.SetMaxOpenConns("rddp", 100)
  17. report_db, _ := orm.GetDB("rddp")
  18. report_db.SetConnMaxLifetime(10 * time.Minute)
  19. orm.RegisterDataBase("tactics", "mysql", utils.MYSQL_URL_TACTICS)
  20. orm.SetMaxIdleConns("tactics", 50)
  21. orm.SetMaxOpenConns("tactics", 100)
  22. tacticsDb, _ := orm.GetDB("tactics")
  23. tacticsDb.SetConnMaxLifetime(10 * time.Minute)
  24. orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
  25. orm.SetMaxIdleConns("comein_data", 50)
  26. orm.SetMaxOpenConns("comein_data", 100)
  27. comein_datadb, _ := orm.GetDB("comein_data")
  28. comein_datadb.SetConnMaxLifetime(10 * time.Minute)
  29. //
  30. //orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
  31. //orm.SetMaxIdleConns("comein_data", 50)
  32. //orm.SetMaxOpenConns("comein_data", 100)
  33. //
  34. //comein_dataDb, _ := orm.GetDB("comein_data")
  35. //comein_dataDb.SetConnMaxLifetime(10 * time.Minute)
  36. //注册对象
  37. orm.RegisterModel(
  38. new(WxUser),
  39. new(CygxSession),
  40. new(WxUserLog),
  41. new(WxUserCode),
  42. new(CygxArticleCollect),
  43. new(CygxArticleViewRecord),
  44. new(CygxAdvice),
  45. new(MsgCode),
  46. new(Resource),
  47. new(CygxApplyRecord),
  48. new(CygxInterviewApply),
  49. new(CygxArticle),
  50. new(CygxArticleHistoryRecord),
  51. new(CygxSearchKeyWord),
  52. new(UserRecord),
  53. new(CygxIndustryTop),
  54. new(CygxActivitySignup),
  55. new(CygxActivitySignupLog),
  56. new(CygxActivityUserSearchContent),
  57. new(CygxActivityMeetingReminder),
  58. new(CygxActivityMeetingReminderLog),
  59. new(CygxMySchedule),
  60. new(WxUserWhite),
  61. new(CygxActivityHelpAsk),
  62. new(CygxIndustryFllow),
  63. new(CygxArticleDepartmentFollow),
  64. new(CygxArticleAsk),
  65. new(CygxPageHistoryRecord),
  66. new(CygxReportHistoryRecord),
  67. new(CygxArticleAuthor),
  68. new(CygxUserRecord),
  69. new(CygxReportIndustrialSeaarchHistory),
  70. new(CygxArticleHistoryRecordNewpv),
  71. new(CygxActivitySearchHistory),
  72. new(CygxActivityAttendanceDetail),
  73. new(CygxActivityRestrictSignup),
  74. new(CygxActivityMeetDetailLog),
  75. new(CygxUserSearchKeyWord),
  76. new(CompanyReportPermission),
  77. new(Company),
  78. new(CompanyLog),
  79. new(CompanyOperationRecord),
  80. new(CompanyPermissionLog),
  81. new(CompanyProduct),
  82. new(CompanyProductLog),
  83. new(UserSellerRelation),
  84. new(CygxShanghaiCompanyLog),
  85. new(CygxShanghaiErrLog),
  86. new(CygxUserFreeeButton),
  87. new(UserInvitee),
  88. new(CygxActivitySpecialSignup),
  89. new(CygxUserFollowSpecial),
  90. new(CygxChart),
  91. new(CygxChartCollect),
  92. new(CygxChartTop),
  93. new(CygxCelueArticleHistoryRecord),
  94. new(CygxArticleHistoryRecordAll),
  95. new(CygxActivityAppointment),
  96. new(UserTemplateRecord),
  97. new(CygxUserInteractionNum),
  98. new(CygxChartCollectByCygx),
  99. new(CygxCompanyInteractionNum),
  100. new(CygxChartAll),
  101. new(CygxSessionMobile),
  102. new(CygxSearchKeyWordLog),
  103. new(CygxActivity),
  104. new(CygxYidongActivityMeetingApiLog),
  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(CygxActivitySignin),
  127. new(CygxActivitySigninLog),
  128. new(CygxActivityOfflineMeetingDetail),
  129. new(CygxProductInteriorHistory),
  130. new(CygxMorningMeetingGather),
  131. new(CygxArticleCategoryMapping),
  132. new(CygxReportMappingCygx),
  133. new(CygxReportMappingGroup),
  134. new(CygxAboutUsVideoHistory),
  135. new(CygxActivitySignupBreak),
  136. new(CygxBannerHistory),
  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. )
  146. // 记录ORM查询日志
  147. orm.Debug = true
  148. orm.DebugLog = orm.NewLog(utils.BinLog)
  149. }