base_from_eia_steo.go 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package models
  2. import (
  3. "time"
  4. "github.com/beego/beego/v2/client/orm"
  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 string `description:"开始日期"`
  22. EndDate string `description:"结束日期"`
  23. ModifyTime string `description:"最新更新时间"`
  24. CreateTime string `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. // BaseFromEiaSteoClassify EiaSteo分类
  36. type BaseFromEiaSteoClassify struct {
  37. BaseFromEiaSteoClassifyId int `orm:"column(base_from_eia_steo_classify_id);pk"`
  38. ClassifyName string `description:"分类名称(中文名称)"`
  39. ClassifyNameOriginal string `description:"分类名称(原始名称)"`
  40. ParentId int `description:"父级id"`
  41. Level int `description:"层级"`
  42. ModifyTime time.Time `description:"最新更新时间"`
  43. CreateTime time.Time `description:"创建时间"`
  44. }
  45. func (obj *BaseFromEiaSteoClassify) GetBaseFromEiaSteoClassifyAll() (list []*BaseFromEiaSteoClassify, err error) {
  46. o := orm.NewOrm()
  47. sql := `SELECT * FROM base_from_eia_steo_classify `
  48. _, err = o.Raw(sql).QueryRows(&list)
  49. return list, err
  50. }
  51. func GetEiaSteoIndex(startDate, endDate string) (list []*BaseFromEiaSteoIndex, err error) {
  52. o := orm.NewOrm()
  53. sql := `SELECT * FROM base_from_eia_steo_index WHERE create_time>=? AND create_time<=? ORDER BY create_time ASC `
  54. _, err = o.Raw(sql, startDate, endDate).QueryRows(&list)
  55. return
  56. }
  57. func GetEiaSteoIndexData(indexCode, startDate, endDate string) (list []*BaseFromEiaSteoData, err error) {
  58. o := orm.NewOrm()
  59. sql := `SELECT * FROM base_from_eia_steo_data WHERE index_code=? AND create_time>=? AND create_time<=? ORDER BY create_time ASC `
  60. _, err = o.Raw(sql, indexCode, startDate, endDate).QueryRows(&list)
  61. return
  62. }