package models import ( "eta/eta_hub/models/data_manage" "eta/eta_hub/models/report" "eta/eta_hub/utils" "time" _ "github.com/go-sql-driver/mysql" "github.com/beego/beego/v2/client/orm" ) func init() { // eta_master _ = 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_report _ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP) orm.SetMaxIdleConns("rddp", 50) orm.SetMaxOpenConns("rddp", 100) reportDb, _ := orm.GetDB("rddp") reportDb.SetConnMaxLifetime(10 * time.Minute) // eta_index _ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA) orm.SetMaxIdleConns("data", 50) orm.SetMaxOpenConns("data", 100) indexDb, _ := orm.GetDB("data") indexDb.SetConnMaxLifetime(10 * time.Minute) orm.Debug = true orm.DebugLog = orm.NewLog(utils.Binlog) // 注册对象 orm.RegisterModel( new(Report), new(EnglishReport), new(SmartReport), new(ReportStateRecord), new(data_manage.EdbSource), new(data_manage.EdbClassify), new(data_manage.EdbInfo), new(report.ReportChapterPermissionMapping), // 报告章节的权限关系表 ) afterInitTable() } // afterInitTable // @Description: 初始化表结构的的后置操作 // @author: Roc // @datetime 2024-07-01 13:31:09 func afterInitTable() { // 初始化指标来源配置 data_manage.InitEdbSource() // 初始化是否启用mongo配置 InitUseMongoConf() }