db.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package models
  2. import (
  3. "eta/eta_index_lib/models/future_good"
  4. "eta/eta_index_lib/models/supply_analysis"
  5. "eta/eta_index_lib/utils"
  6. "github.com/beego/beego/v2/client/orm"
  7. _ "github.com/go-sql-driver/mysql"
  8. "time"
  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("edb", "mysql", utils.MYSQL_URL_EDB)
  17. orm.SetMaxIdleConns("edb", 50)
  18. orm.SetMaxOpenConns("edb", 100)
  19. edb_db, _ := orm.GetDB("edb")
  20. edb_db.SetConnMaxLifetime(10 * time.Minute)
  21. _ = orm.RegisterDataBase("gl", "mysql", utils.MYSQL_URL_GL)
  22. orm.SetMaxIdleConns("gl", 50)
  23. orm.SetMaxOpenConns("gl", 100)
  24. gl, _ := orm.GetDB("gl")
  25. gl.SetConnMaxLifetime(10 * time.Minute)
  26. orm.Debug = true
  27. orm.DebugLog = orm.NewLog(utils.Binlog)
  28. //注册对象
  29. orm.RegisterModel(
  30. new(EdbDataCalculateZjpj),
  31. new(EdbDataCalculateLjztbpj),
  32. new(EdbInfo),
  33. new(EdbInfoCalculateMapping),
  34. new(EdbPythonCode),
  35. new(EdbDataPython),
  36. new(ChartEdbMapping),
  37. new(PredictEdbConf),
  38. new(EdbClassify),
  39. new(PredictEdbConfCalculateMapping),
  40. new(PredictEdbRuleData),
  41. new(EdbDataCalculateNhcc),
  42. new(EdbDataPredictCalculateLjztbpj),
  43. new(EdbDataPredictCalculateNhcc),
  44. new(EdbDataPredictCalculateZjpj),
  45. new(EdbDataInsertConfig),
  46. new(EdbAdjustConf), // 数据调整的配置
  47. new(BaseFromMysteelChemicalClassify),
  48. )
  49. // 注册期货数据 数据表
  50. initFutureGood()
  51. // 供应分析 数据表
  52. initSupplyAnalysis()
  53. // 基础指标表
  54. initBaseIndex()
  55. }
  56. // initFutureGood 注册期货数据 数据表
  57. func initFutureGood() {
  58. //注册对象
  59. orm.RegisterModel(
  60. new(future_good.FutureGoodEdbInfo), //期货指标表
  61. new(future_good.FutureGoodEdbData), //期货指标数据表
  62. new(future_good.ChartInfoFutureGoodProfit), //商品期货利润图表相关的信息
  63. )
  64. }
  65. // initSupplyAnalysis 供应分析
  66. func initSupplyAnalysis() {
  67. orm.RegisterModel(
  68. new(supply_analysis.Variety),
  69. new(supply_analysis.VarietyAdminPermission),
  70. new(supply_analysis.VarietyEdbInfo),
  71. new(supply_analysis.VarietyPlant),
  72. new(supply_analysis.BaseFromStockPlantData),
  73. )
  74. }
  75. // initBaseIndex 基础指标表
  76. func initBaseIndex() {
  77. orm.RegisterModel(
  78. new(BaseFromSciIndex),
  79. new(BaseFromSciData),
  80. new(BaseFromBaiinfoIndex),
  81. new(BaseFromBaiinfoData),
  82. new(BaseFromSmmIndex),
  83. new(BaseFromSmmData),
  84. new(BaseFromMysteelChemicalIndex),
  85. new(BaseFromMysteelChemicalData),
  86. )
  87. }