db.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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)
  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. //注册对象
  20. orm.RegisterModel(
  21. new(WxUser),
  22. new(WxUserCode),
  23. new(UserRecord),
  24. new(CygxUserRecord),
  25. new(CygxClptSession),
  26. new(CygxIndustryFllow),
  27. new(MsgCode),
  28. new(CygxArticleCollect),
  29. new(CygxInterviewApply),
  30. new(CygxArticleAsk),
  31. new(CygxSearchKeyWord),
  32. new(CygxSearchKeyWordLog),
  33. new(Resource),
  34. new(CygxXzsChooseCategory),
  35. new(CygxReportIndustrialSeaarchHistory),
  36. new(CygxMicroRoadshowVideoHistory),
  37. new(CygxActivitySignup),
  38. new(CygxActivitySignupLog),
  39. new(CygxMySchedule),
  40. new(CygxActivitySpecialSignup),
  41. new(CygxUserFollowSpecial),
  42. new(CygxActivitySpecialTrip),
  43. new(CygxActivityMeetingReminder),
  44. new(CygxActivityMeetingReminderLog),
  45. new(CygxActivityAppointment),
  46. new(CygxActivityHelpAsk),
  47. new(UserTemplateRecord),
  48. new(CygxAdvice),
  49. new(CygxPageHistoryRecord),
  50. new(CygxArticleDepartmentFollow),
  51. new(CygxArticleComment),
  52. new(CygxArticleHistoryRecordNewpv),
  53. new(CygxArticleHistoryRecord),
  54. new(CygxArticleHistoryRecordAll),
  55. new(CygxActivitySpecialTripBill),
  56. new(CygxReportHistoryRecord),
  57. new(CygxReportSelectionSubjectHistory),
  58. new(CygxMinutesSummaryVoiceHistory),
  59. new(CygxResearchSummaryVoiceHistory),
  60. )
  61. // 记录ORM查询日志
  62. orm.Debug = true
  63. orm.DebugLog = orm.NewLog(utils.BinLog)
  64. }