db.go 704 B

123456789101112131415161718192021222324252627282930313233343536
  1. package models
  2. import (
  3. "hongze/hongze_cygx/utils"
  4. _ "github.com/go-sql-driver/mysql"
  5. "time"
  6. "rdluck_tools/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(CygxSession),
  23. new(WxUserLog),
  24. new(WxUserCode),
  25. new(CygxArticleCollect),
  26. )
  27. }