db_init.go 751 B

12345678910111213141516171819202122232425262728293031323334
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. "hongze/hongze_open_api/models/tables/open_api_user"
  5. "hongze/hongze_open_api/utils"
  6. "rdluck_tools/orm"
  7. "time"
  8. )
  9. func init() {
  10. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  11. orm.SetMaxIdleConns("default", 50)
  12. orm.SetMaxOpenConns("default", 100)
  13. db, _ := orm.GetDB("default")
  14. db.SetConnMaxLifetime(10 * time.Minute)
  15. //rddp数据库
  16. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  17. orm.SetMaxIdleConns("rddp", 50)
  18. orm.SetMaxOpenConns("rddp", 100)
  19. report_db, _ := orm.GetDB("rddp")
  20. report_db.SetConnMaxLifetime(10 * time.Minute)
  21. //注册对象
  22. orm.RegisterModel(
  23. new(open_api_user.OpenApiUser), //开放API用户表
  24. )
  25. }
  26. func InitDb() {}