base_from_usda_fas.go 3.4 KB

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