base_from_trade_eic.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BaseFromTradeEicIndex struct {
  7. BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"`
  8. Country string
  9. Type string
  10. EicCode string
  11. ShortName string
  12. Name string
  13. Status string
  14. GasDayStartedOn string
  15. GasInStorage float64
  16. GasInStorageCode string
  17. Full float64
  18. FullCode string
  19. Trend float64
  20. TrendCode string
  21. Injection float64
  22. InjectionCode string
  23. Withdrawal float64
  24. WithdrawalCode string
  25. WorkingGasVolume float64
  26. WorkingGasVolumeCode string
  27. InjectionCapacity float64
  28. InjectionCapacityCode string
  29. WithdrawalCapacity float64
  30. WithdrawalCapacityCode string
  31. Info string
  32. CreateTime time.Time
  33. ModifyTime time.Time
  34. }
  35. type BaseFromTradeMapping struct {
  36. BaseFromTradeMappingId int `orm:"column(base_from_trade_mapping_id);pk"`
  37. IndexName string
  38. IndexCode string
  39. Exchange string
  40. }
  41. func AddBaseFromEicIndex(item *BaseFromTradeEicIndex) (lastId int64, err error) {
  42. o := orm.NewOrmUsingDB("data")
  43. lastId, err = o.Insert(item)
  44. return
  45. }
  46. func GetSSOFromEicIndexAll(name string) (list []*BaseFromTradeEicIndex, err error) {
  47. o := orm.NewOrmUsingDB("data")
  48. sql := `SELECT * FROM base_from_trade_eic_index where name=? and type='SSO'`
  49. _, err = o.Raw(sql, name).QueryRows(&list)
  50. return
  51. }
  52. func GetFacFromEicIndexAll(name string) (list []*BaseFromTradeEicIndex, err error) {
  53. o := orm.NewOrmUsingDB("data")
  54. sql := `SELECT * FROM base_from_trade_eic_index where name=? and type='Storage Facility'`
  55. _, err = o.Raw(sql, name).QueryRows(&list)
  56. return
  57. }
  58. func ModifyBaseFromEicIndex(gasInStorage, full, trend, injection, withdrawal float64, dataId int) (err error) {
  59. o := orm.NewOrmUsingDB("data")
  60. sql := `UPDATE base_from_trade_eic_index SET gas_in_storage=?,full=?,trend=?,injection=?,withdrawal=?,modify_time=NOW() WHERE base_from_eic_index_id=? `
  61. _, err = o.Raw(sql, gasInStorage, full, trend, injection, withdrawal, dataId).Exec()
  62. return
  63. }
  64. func GetCountryFromEicIndexAll(name string) (list []*BaseFromTradeEicIndex, err error) {
  65. o := orm.NewOrmUsingDB("data")
  66. sql := `SELECT * FROM base_from_trade_eic_index where country=? and (type='country' or type='continent')`
  67. _, err = o.Raw(sql, name).QueryRows(&list)
  68. return
  69. }
  70. func AddEicDataMulti(items []*BaseFromTradeEicIndex) (successNums int64, err error) {
  71. o := orm.NewOrmUsingDB("data")
  72. successNums, err = o.InsertMulti(1, items)
  73. return
  74. }
  75. func AddEicCodeMulti(items []*BaseFromTradeMapping) (successNums int64, err error) {
  76. o := orm.NewOrmUsingDB("data")
  77. successNums, err = o.InsertMulti(1, items)
  78. return
  79. }