package models import ( "eta/eta_report/utils" _ "github.com/go-sql-driver/mysql" "time" "github.com/beego/beego/v2/client/orm" ) func init() { // eta_report _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL) orm.SetMaxIdleConns("default", 50) orm.SetMaxOpenConns("default", 100) db, _ := orm.GetDB("default") db.SetConnMaxLifetime(10 * time.Minute) // eta_master _ = orm.RegisterDataBase("eta", "mysql", utils.MYSQL_URL_ETA) orm.SetMaxIdleConns("eta", 50) orm.SetMaxOpenConns("eta", 100) etaDb, _ := orm.GetDB("eta") etaDb.SetConnMaxLifetime(10 * time.Minute) // crm_master if utils.MYSQL_WEEKLY_URL != `` && utils.BusinessCode == utils.BusinessCodeRelease { _ = orm.RegisterDataBase("weekly", "mysql", utils.MYSQL_WEEKLY_URL) orm.SetMaxIdleConns("weekly", 50) orm.SetMaxOpenConns("weekly", 100) weeklyDb, _ := orm.GetDB("weekly") weeklyDb.SetConnMaxLifetime(10 * time.Minute) } orm.Debug = true orm.DebugLog = orm.NewLog(utils.Binlog) //注册对象 orm.RegisterModel( new(Report), new(SmartReport), ) }