base_from_icpi.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 BaseFromIcpiIndex struct {
  8. BaseFromIcpiIndexId int `orm:"column(base_from_icpi_index_id);pk"`
  9. BaseFromIcpiClassifyId int `description:"分类id"`
  10. IndexCode string `description:"指标编码"`
  11. IndexName string `description:"指标名称"`
  12. Frequency string `description:"频度"`
  13. StartDate time.Time `description:"开始日期"`
  14. EndDate time.Time `description:"结束日期"`
  15. CreateTime time.Time `description:"创建时间"`
  16. ModifyTime time.Time `description:"修改时间"`
  17. }
  18. type BaseFromIcpiData struct {
  19. BaseFromIcpiDataId int `orm:"column(base_from_icpi_data_id);pk"`
  20. BaseFromIcpiIndexId int `description:"指标id"`
  21. IndexCode string `description:"指标编码"`
  22. DataTime string `description:"日期"`
  23. Value string `description:"值"`
  24. CreateTime time.Time `description:"创建时间"`
  25. ModifyTime time.Time `description:"修改时间"`
  26. }
  27. type BaseFromIcpiClassify struct {
  28. BaseFromIcpiClassifyId int `orm:"column(base_from_icpi_classify_id);pk"`
  29. ClassifyName string `description:"分类名称"`
  30. ClassifyNameEn string `description:"英文名称"`
  31. ParentId int `description:"上级id"`
  32. CreateTime string `description:"创建时间"`
  33. ModifyTime string `description:"修改时间"`
  34. }
  35. func (obj *BaseFromIcpiIndex) GetBaseFromIcpiClassifyAll() (list []*BaseFromIcpiClassify, err error) {
  36. o := orm.NewOrm()
  37. sql := `SELECT * FROM base_from_icpi_classify `
  38. _, err = o.Raw(sql).QueryRows(&list)
  39. return
  40. }
  41. type BaseFromIcpiDataView struct {
  42. BaseFromIcpiDataId int `orm:"column(base_from_icpi_data_id);pk"`
  43. BaseFromIcpiIndexId 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. type BaseFromIcpiIndexView struct {
  51. BaseFromIcpiIndexId int `description:"指标id"`
  52. BaseFromIcpiClassifyId int `description:"分类id"`
  53. IndexCode string `description:"指标编码"`
  54. IndexName string `description:"指标名称"`
  55. Frequency string `description:"频度"`
  56. Unit string `description:"单位"`
  57. StartDate string `description:"开始日期"`
  58. EndDate string `description:"结束日期"`
  59. CreateTime string `description:"创建时间"`
  60. ModifyTime string `description:"修改时间"`
  61. }
  62. func GetIcpiIndex(startDate, endDate string) (items []*BaseFromIcpiIndex, err error) {
  63. o := orm.NewOrm()
  64. sql := ` SELECT * FROM base_from_icpi_index WHERE end_date >= ? AND end_date <= ? `
  65. _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
  66. return
  67. }
  68. func GetBaseFromIcpiData(indexCode, startDate, endDate string) (list []*BaseFromIcpiData, err error) {
  69. o := orm.NewOrm()
  70. sql := `SELECT * FROM base_from_icpi_data WHERE index_code=? AND modify_time>=? AND modify_time<=? `
  71. _, err = o.Raw(sql, indexCode, startDate, endDate).QueryRows(&list)
  72. return
  73. }
  74. // GetComTradeDataList 获取icpi消费指数数据列表
  75. func GetBaseFromIcpiDataList(startDate, endDate string, startSize, pageSize int) (total int, list []*BaseFromIcpiData, err error) {
  76. o := orm.NewOrm()
  77. totalSql := `SELECT count(1) total FROM base_from_icpi_data WHERE create_time>=? AND create_time<=? `
  78. err = o.Raw(totalSql, startDate, endDate).QueryRow(&total)
  79. if err != nil {
  80. return
  81. }
  82. sql := `SELECT * FROM base_from_icpi_data WHERE create_time>=? AND create_time<=? ORDER BY base_from_icpi_data_id ASC LIMIT ?,?`
  83. _, err = o.Raw(sql, startDate, endDate, startSize, pageSize).QueryRows(&list)
  84. return
  85. }
  86. // ComTradeIndexDataResp 分页列表响应体
  87. type BaseFromIcpiDataResp struct {
  88. List []*BaseFromIcpiData
  89. Paging *paging.PagingItem `description:"分页数据"`
  90. }