1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package models
- import (
- "eta/eta_forum_task/utils"
- "github.com/beego/beego/v2/client/orm"
- _ "github.com/go-sql-driver/mysql"
- "time"
- )
- 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("data", "mysql", utils.MYSQL_URL_DATA)
- orm.SetMaxIdleConns("data", 50)
- orm.SetMaxOpenConns("data", 100)
- data_db, _ := orm.GetDB("data")
- data_db.SetConnMaxLifetime(10 * time.Minute)
- _ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
- orm.SetMaxIdleConns("gl", 50)
- orm.SetMaxOpenConns("gl", 100)
- gl, _ := orm.GetDB("gl")
- gl.SetConnMaxLifetime(10 * time.Minute)
- orm.Debug = true
- orm.DebugLog = orm.NewLog(utils.Binlog)
- initChart()
- initEdbData()
- afterInitTable()
- }
- // initChart 图表 数据表
- func initChart() {
- orm.RegisterModel(
- new(ChartClassify),
- new(ChartInfo),
- new(ChartEdbMapping),
- new(ChartTheme),
- new(ChartThemeType),
- )
- }
- // initEdbData 指标服务 数据表
- func initEdbData() {
- orm.RegisterModel(
- new(EdbInfoCalculateMapping),
- new(EdbInfo),
- )
- }
- // afterInitTable
- // @Description: 初始化表结构的的后置操作
- // @author: Roc
- // @datetime 2024-07-01 13:31:09
- func afterInitTable() {
- InitEdbSourceVar()
- // 初始化是否启用mongo配置
- InitUseMongoConf()
- }
|