package models import ( "eta/eta_pub/utils" _ "github.com/go-sql-driver/mysql" "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("cygx", "mysql", utils.MYSQL_URL_CYGX) orm.SetMaxIdleConns("cygx", 50) orm.SetMaxOpenConns("cygx", 100) cygx_db, _ := orm.GetDB("cygx") cygx_db.SetConnMaxLifetime(10 * time.Minute) //注册对象 orm.RegisterModel( new(UserTemplateRecord), new(ReportChapter), new(TemplateLibrary), ) }