123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package models
- import (
- _ "github.com/go-sql-driver/mysql"
- "hongze/hongze_mfyx_gzh/utils"
- "time"
- "github.com/beego/beego/v2/client/orm"
- )
- func init() {
- _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_CYGX)
- orm.SetMaxIdleConns("default", 50)
- orm.SetMaxOpenConns("default", 100)
- cygx_db, _ := orm.GetDB("default")
- cygx_db.SetConnMaxLifetime(10 * time.Minute)
- _ = orm.RegisterDataBase("weekly_report", "mysql", utils.MYSQL_URL)
- orm.SetMaxIdleConns("weekly_report", 50)
- orm.SetMaxOpenConns("weekly_report", 100)
- db, _ := orm.GetDB("weekly_report")
- db.SetConnMaxLifetime(10 * time.Minute)
- //注册对象
- orm.RegisterModel(
- new(WxUser),
- new(WxUserLog),
- new(WxUserCode),
- new(UserRecord),
- new(CygxMfyxGzhUserRecord),
- new(CygxMfyxGzhSession),
- new(CygxIndustryFllow),
- new(CygxThreeApiLog),
- )
- // 记录ORM查询日志
- orm.Debug = true
- orm.DebugLog = orm.NewLog(utils.Binlog)
- }
|