db.go 503 B

1234567891011121314151617181920212223242526272829
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. "hongze/hongze_cygxzs/utils"
  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. //注册对象
  15. orm.RegisterModel(
  16. new(WxUser),
  17. new(CygxSession),
  18. new(WxUserLog),
  19. new(WxUserCode),
  20. new(UserRecord),
  21. new(CygxUserRecord),
  22. )
  23. }