1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package models
- import (
- _ "github.com/go-sql-driver/mysql"
- "hongze/hongze_cygxzs/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("hz_cygx", "mysql", utils.MYSQL_URL_CYGX)
- orm.SetMaxIdleConns("hz_cygx", 50)
- orm.SetMaxOpenConns("hz_cygx", 100)
- cygx_db, _ := orm.GetDB("hz_cygx")
- cygx_db.SetConnMaxLifetime(10 * time.Minute)
- //注册对象
- orm.RegisterModel(
- new(WxUser),
- new(WxUserLog),
- new(WxUserCode),
- new(UserRecord),
- new(CygxUserRecord),
- new(CygxXzsSession),
- new(CygxXzsChooseSend),
- new(CygxIndustryFllow),
- new(CygxXzsChooseCategory),
- new(CygxXzsChooseCategoryZhouqi), //周期的关注系列
- )
- // 记录ORM查询日志
- orm.Debug = true
- orm.DebugLog = orm.NewLog(utils.BinLog)
- }
|