db.go 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package models
  2. import (
  3. "eta/eta_mini_crm/utils"
  4. "time"
  5. "github.com/beego/beego/v2/client/orm"
  6. _ "github.com/go-sql-driver/mysql"
  7. )
  8. func init() {
  9. _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
  10. orm.SetMaxIdleConns("rddp", 50)
  11. orm.SetMaxOpenConns("rddp", 100)
  12. report_db, _ := orm.GetDB("rddp")
  13. report_db.SetConnMaxLifetime(10 * time.Minute)
  14. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_MASTER)
  15. orm.SetMaxIdleConns("default", 50)
  16. orm.SetMaxOpenConns("default", 100)
  17. db, _ := orm.GetDB("default")
  18. db.SetConnMaxLifetime(10 * time.Minute)
  19. orm.Debug = true
  20. orm.DebugLog = orm.NewLog(utils.BinLog)
  21. orm.RegisterModel(
  22. new(SysSession),
  23. new(SysRole),
  24. new(SysUser),
  25. new(SysDepartment),
  26. new(SysMenu),
  27. new(SysRoleMenuMapping),
  28. new(ChartPermission),
  29. new(UserChartPermissionMapping),
  30. new(User),
  31. new(SysMessageReport),
  32. new(CrmConfig),
  33. new(UserChangeRecord),
  34. new(ReportPdf),
  35. new(ReportPushStatus),
  36. )
  37. }