db.go 3.3 KB

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