package models import ( _ "github.com/go-sql-driver/mysql" "hongze/hongze_api/utils" "time" "github.com/beego/beego/v2/client/orm" ) func init() { _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL) orm.SetMaxIdleConns("default", 50) orm.SetMaxOpenConns("default", 100) db, _ := orm.GetDB("default") db.SetConnMaxLifetime(10 * time.Minute) _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP) orm.SetMaxIdleConns("rddp", 50) orm.SetMaxOpenConns("rddp", 100) report_db, _ := orm.GetDB("rddp") report_db.SetConnMaxLifetime(10 * time.Minute) //_ = orm.RegisterDataBase("edb", "mysql", utils.MYSQL_URL_EDB) //orm.SetMaxIdleConns("edb", 50) //orm.SetMaxOpenConns("edb", 100) //edb_db, _ := orm.GetDB("edb") //edb_db.SetConnMaxLifetime(10 * time.Minute) _ = orm.RegisterDataBase("rddp_trial", "mysql", utils.MYSQL_URL_RDDP_TRIAL) orm.SetMaxIdleConns("rddp_trial", 50) orm.SetMaxOpenConns("rddp_trial", 100) rddpTrial, _ := orm.GetDB("rddp_trial") rddpTrial.SetConnMaxLifetime(10 * time.Minute) // ETA默认库 _ = 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) orm.Debug = true orm.DebugLog = orm.NewLog(utils.Binlog) //注册对象 orm.RegisterModel( new(ReportAudioRecord), new(ReportViewLog), new(ReportViewRecord), new(WxUser), new(Session), new(MsgCode), new(GraphicVerifyCode), new(AnnualReport), new(WxUserLog), new(UserAccessRecord), new(WxUserCode), new(UserRecord), new(YbApplyRecord), new(EnglishReportEmailPV), ) }