db.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. "hongze/hongze_clpt/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. //注册对象
  25. orm.RegisterModel(
  26. new(WxUser),
  27. new(WxUserCode),
  28. new(UserRecord),
  29. new(CygxUserRecord),
  30. new(CygxClptSession),
  31. new(CygxIndustryFllow),
  32. new(MsgCode),
  33. new(CygxArticleCollect),
  34. new(CygxInterviewApply),
  35. new(CygxArticleAsk),
  36. new(CygxSearchKeyWord),
  37. new(CygxSearchKeyWordLog),
  38. new(Resource),
  39. new(CygxXzsChooseCategory),
  40. new(CygxReportIndustrialSeaarchHistory),
  41. new(CygxMicroRoadshowVideoHistory),
  42. new(CygxActivitySignup),
  43. new(CygxActivitySignupLog),
  44. new(CygxMySchedule),
  45. new(CygxActivitySpecialSignup),
  46. new(CygxUserFollowSpecial),
  47. new(CygxActivitySpecialTrip),
  48. new(CygxActivityMeetingReminder),
  49. new(CygxActivityMeetingReminderLog),
  50. new(CygxActivityAppointment),
  51. new(CygxActivityHelpAsk),
  52. new(UserTemplateRecord),
  53. new(CygxAdvice),
  54. new(CygxPageHistoryRecord),
  55. new(CygxArticleDepartmentFollow),
  56. new(CygxArticleComment),
  57. new(CygxArticleViewRecord),
  58. new(CygxArticleHistoryRecordNewpv),
  59. new(CygxArticleHistoryRecord),
  60. new(CygxArticleHistoryRecordAll),
  61. new(CygxActivitySpecialTripBill),
  62. new(CygxReportHistoryRecord),
  63. new(CygxReportSelectionSubjectHistory),
  64. new(CygxMinutesSummaryVoiceHistory),
  65. new(CygxResearchSummaryVoiceHistory),
  66. new(CygxProductInteriorHistory),
  67. new(CygxAboutUsVideoHistory),
  68. new(CygxTacticsTimeLineHistory),
  69. new(CygxBannerHistory),
  70. new(CygxReportHistoryRecordLog),
  71. new(CygxUserLabel),
  72. new(CygxInviteCompany),
  73. new(CygxApplyRecord),
  74. new(CygxTagHistory),
  75. new(CygxActivitySpecialMeetingDetail),
  76. new(CygxActivityVoiceHistory),
  77. new(CygxApplyCollection),
  78. new(CygxActivitySpecialInheritPointsCompany),
  79. new(CygxArticleApplyAppointmentExpert),
  80. new(CygxBannerYxSurvey),
  81. new(CygxReportSelectionLogApply),
  82. new(CygxIndustryFllowLog),
  83. new(CygxYanxuanSpecialRecord),
  84. new(CygxYanxuanSpecialRecordLog),
  85. new(CygxYanxuanSpecialCollect),
  86. new(CygxYanxuanSpecial),
  87. new(CygxYanxuanSpecialFollow),
  88. new(CygxYanxuanSpecialCompany),
  89. new(CygxYanxuanSpecialApprovalLog),
  90. new(CygxResourceData),
  91. new(CygxMorningMeetingReviewChapterHistory),
  92. new(CygxAskserieVideoHistoryRecord),
  93. new(CygxAskserieVideoCollection),
  94. new(CygxAskserieVideoCollect),
  95. new(CygxVoiceAndVideoHistory),
  96. new(CygxActivityVideoHistory),
  97. new(CygxTimelineLog),
  98. new(CygxActivitySpecialPermissionPoints),
  99. new(CygxXzsChooseCategoryZhouqi),
  100. )
  101. // 记录ORM查询日志
  102. orm.Debug = true
  103. orm.DebugLog = orm.NewLog(utils.Binlog)
  104. }