base_from_usda_fas.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type BaseFromUsdaFasIndex struct {
  8. BaseFromUsdaFasIndexId int `orm:"column(base_from_usda_fas_index_id);pk"`
  9. ClassifyId int
  10. IndexCode string
  11. IndexName string
  12. Frequency string
  13. Unit string
  14. Sort int
  15. StartDate time.Time `description:"开始日期"`
  16. EndDate time.Time `description:"结束日期"`
  17. EndValue float64
  18. CreateTime time.Time
  19. ModifyTime time.Time
  20. }
  21. // BaseFromUsdaFasClassify UsdaFas原始数据分类表
  22. type BaseFromUsdaFasClassify struct {
  23. ClassifyId int `orm:"column(classify_id);pk"`
  24. ClassifyName string `description:"分类名称"`
  25. ParentId int `description:"父级id"`
  26. SysUserId int `description:"创建人id"`
  27. SysUserRealName string `description:"创建人姓名"`
  28. Level int `description:"层级"`
  29. Sort int `description:"排序字段,越小越靠前,默认值:10"`
  30. ModifyTime time.Time `description:"修改时间"`
  31. CreateTime time.Time `description:"创建时间"`
  32. }
  33. func (obj *BaseFromUsdaFasClassify) GetBaseFromUsdaFasClassifyAll() (list []*BaseFromUsdaFasClassify, err error) {
  34. o := orm.NewOrm()
  35. sql := `SELECT * FROM base_from_usda_fas_classify `
  36. _, err = o.Raw(sql).QueryRows(&list)
  37. return
  38. }
  39. type BaseFromUsdaFasData struct {
  40. BaseFromUsdaFasDataId int `orm:"column(base_from_usda_fas_data_id);pk"`
  41. BaseFromUsdaFasIndexId int `description:"指标id"`
  42. IndexCode string `description:"指标编码"`
  43. DataTime string `description:"日期"`
  44. Value string `description:"值"`
  45. CreateTime time.Time `description:"创建时间"`
  46. ModifyTime time.Time `description:"修改时间"`
  47. }
  48. func GetUsdaFasIndex(startDate, endDate string) (items []*BaseFromUsdaFasIndex, err error) {
  49. o := orm.NewOrm()
  50. sql := ` SELECT * FROM base_from_usda_fas_index WHERE modify_time >= ? AND modify_time <= ? `
  51. _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
  52. return
  53. }
  54. func GetBaseFromUsdaFasData(indexCode, startDate, endDate string) (list []*BaseFromUsdaFasData, err error) {
  55. o := orm.NewOrm()
  56. sql := `SELECT * FROM base_from_usda_fas_data WHERE index_code=? AND modify_time>=? AND modify_time<=? `
  57. _, err = o.Raw(sql, indexCode, startDate, endDate).QueryRows(&list)
  58. return
  59. }
  60. // GetComTradeDataList 获取UsdaFas消费指数数据列表
  61. func GetBaseFromUsdaFasDataList(startDate, endDate string, startSize, pageSize int) (total int, list []*BaseFromUsdaFasData, err error) {
  62. o := orm.NewOrm()
  63. totalSql := `SELECT count(1) total FROM base_from_usda_fas_data WHERE modify_time>=? AND modify_time<=? `
  64. err = o.Raw(totalSql, startDate, endDate).QueryRow(&total)
  65. if err != nil {
  66. return
  67. }
  68. sql := `SELECT * FROM base_from_usda_fas_data WHERE modify_time>=? AND modify_time<=? ORDER BY base_from_usda_fas_data_id ASC LIMIT ?,?`
  69. _, err = o.Raw(sql, startDate, endDate, startSize, pageSize).QueryRows(&list)
  70. return
  71. }
  72. // ComTradeIndexDataResp 分页列表响应体
  73. type BaseFromUsdaFasDataResp struct {
  74. List []*BaseFromUsdaFasData
  75. Paging *paging.PagingItem `description:"分页数据"`
  76. }