package models import ( "github.com/beego/beego/v2/client/orm" _ "github.com/go-sql-driver/mysql" "hongze/hongze_open_api/models/tables/admin" "hongze/hongze_open_api/models/tables/article" "hongze/hongze_open_api/models/tables/company" "hongze/hongze_open_api/models/tables/company_product" "hongze/hongze_open_api/models/tables/open_api_user" "hongze/hongze_open_api/models/tables/qs_event" "hongze/hongze_open_api/models/tables/qs_event_user" "hongze/hongze_open_api/models/tables/wx_user" "hongze/hongze_open_api/models/tables/yb_activity" "hongze/hongze_open_api/utils" "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) //rddp数据库 _ = 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.RegisterModel( new(open_api_user.OpenApiUser), //开放API用户表 new(admin.Admin), //系统用户表 new(article.CygxArticleCeluePush), //策略平台推送过来更新的文章 ) orm.Debug = true orm.DebugLog = orm.NewLog(utils.Binlog) // 注册研报相关的表 initYb() // 注册客户相关的表 initCompany() } // initYb 研报活动相关 func initYb() { orm.RegisterModel( new(yb_activity.Activity), //研报活动 new(qs_event.QsEvent), //全时与ficc研报活动的关系表 new(qs_event_user.QsEventUser), //全时参会信息 ) } // initCompany 注册客户相关的 func initCompany() { orm.RegisterModel( new(company.Company), //company客户表 new(company_product.CompanyProduct), //company_product客户产品表 new(wx_user.WxUser), //微信用户表 ) }