db.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package models
  2. import (
  3. _ "github.com/go-sql-driver/mysql"
  4. "hongze/eta_server/eta_chart_lib/models/data_manage"
  5. "hongze/eta_server/eta_chart_lib/models/data_manage/future_good"
  6. "hongze/eta_server/eta_chart_lib/utils"
  7. "time"
  8. "github.com/beego/beego/v2/client/orm"
  9. )
  10. func init() {
  11. _ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL)
  12. orm.SetMaxIdleConns("default", 50)
  13. orm.SetMaxOpenConns("default", 100)
  14. db, _ := orm.GetDB("default")
  15. db.SetConnMaxLifetime(10 * time.Minute)
  16. _ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA)
  17. orm.SetMaxIdleConns("data", 50)
  18. orm.SetMaxOpenConns("data", 100)
  19. data_db, _ := orm.GetDB("data")
  20. data_db.SetConnMaxLifetime(10 * time.Minute)
  21. orm.Debug = true
  22. orm.DebugLog = orm.NewLog(utils.Binlog)
  23. //注册对象
  24. orm.RegisterModel(
  25. new(data_manage.EdbInfo),
  26. new(ShareChartRefreshLog), //分享图表刷新日志表
  27. new(ExcelInfo), //excel表格
  28. new(data_manage.PredictEdbConf), //预测指标配置
  29. new(data_manage.PredictEdbRuleData), //预测指标配置生成的数据
  30. new(data_manage.PredictEdbConfCalculateMapping), //预测指标关系表
  31. new(data_manage.ChartInfoCorrelation), // 图表相关性信息
  32. )
  33. // 期货数据库
  34. initFutureGood()
  35. }
  36. // initFutureGood 注册期货数据 数据表
  37. func initFutureGood() {
  38. //注册对象
  39. orm.RegisterModel(
  40. new(future_good.FutureGoodEdbInfo), //期货指标表
  41. new(future_good.FutureGoodEdbData), //期货指标数据表
  42. new(future_good.ChartInfoFutureGoodProfit), //期货利润图的扩展表
  43. )
  44. }