base_from_eia_steo.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // BaseFromEiaSteoIndex EiaSteo指标
  7. type BaseFromEiaSteoIndex struct {
  8. BaseFromEiaSteoIndexId int `orm:"column(base_from_eia_steo_index_id);pk"`
  9. BaseFromEiaSteoClassifyId int `description:"指标分类id"`
  10. IndexCode string `description:"指标编码"`
  11. IndexName string `description:"指标名称(中文名称)"`
  12. IndexNameOriginal string `description:"指标名称(原始名称)"`
  13. Frequency string `description:"频度"`
  14. Level int `description:"指标层级(原始层级)"`
  15. Unit string `description:"单位"`
  16. Super string `description:"我也不知道是个啥,反正先存起来,万一用到了呢"`
  17. Precision int `description:"精度,我也不知道会不会用到,反正先存起来,万一用到了呢"`
  18. LastHistorical string `description:"最近的历史记录,我也不知道会不会用到,反正先存起来,万一用到了呢"`
  19. Description string `description:"备注信息,我也不知道会不会用到,反正先存起来,万一用到了呢"`
  20. IsMappable int `description:"是否可映射,我也不知道会不会用到,反正先存起来,万一用到了呢"`
  21. StartDate time.Time `description:"开始日期"`
  22. EndDate time.Time `description:"结束日期"`
  23. ModifyTime time.Time `description:"最新更新时间"`
  24. CreateTime time.Time `description:"创建时间"`
  25. }
  26. type BaseFromEiaSteoData struct {
  27. BaseFromEiaSteoDataId int `orm:"column(base_from_eia_steo_data_id);pk"`
  28. BaseFromEiaSteoIndexId int `description:"指标id"`
  29. IndexCode string `description:"指标编码"`
  30. DataTime time.Time `description:"数据日期"`
  31. Value float64 `description:"数据值"`
  32. ModifyTime time.Time `description:"最新更新时间"`
  33. CreateTime time.Time `description:"创建时间"`
  34. }
  35. func GetEiaSteoIndex(startDate, endDate string) (list []*BaseFromTradeDalianIndex, err error) {
  36. o := orm.NewOrm()
  37. sql := `SELECT * FROM base_from_eia_steo_index WHERE create_time>=? AND create_time<=? ORDER BY create_time ASC `
  38. _, err = o.Raw(sql, startDate, endDate).QueryRows(&list)
  39. return
  40. }
  41. func GetEiaSteoIndexData(indexCode, startDate, endDate string) (list []*BaseFromEiaSteoData, err error) {
  42. o := orm.NewOrm()
  43. sql := `SELECT * FROM base_from_eia_steo_data WHERE index_code=? AND create_time>=? AND create_time<=? ORDER BY create_time ASC `
  44. _, err = o.Raw(sql, indexCode, startDate, endDate).QueryRows(&list)
  45. return
  46. }