base_from_trade_guangzhou.go 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 BaseFromTradeGuangzhouIndex struct {
  8. BaseFromTradeGuangzhouIndexId int `orm:"column(base_from_trade_guangzhou_index_id);pk"`
  9. BaseFromTradeGuangzhouClassifyId int `description:"分类id"`
  10. BaseFromTradeGuangzhouContractId int `description:"合约id"`
  11. IndexCode string `description:"指标编码"`
  12. IndexName string `description:"指标名称"`
  13. Frequency string `description:"频率"`
  14. Unit string `description:"单位"`
  15. StartDate string `description:"开始日期"`
  16. EndDate string `description:"结束日期"`
  17. CreateTime time.Time `description:"创建日期"`
  18. ModifyTime time.Time `description:"修改日期"`
  19. Value float64 `description:"数据值"`
  20. }
  21. type BaseFromTradeGuangzhouClassify struct {
  22. BaseFromTradeGuangzhouClassifyId int `orm:"column(base_from_trade_guangzhou_classify_id);pk"`
  23. ClassifyName string `description:"分类名称"`
  24. ClassifyCode string `description:"分类编码"`
  25. ParentId int `description:"分类父级id"`
  26. ModifyTime time.Time `description:"修改时间"`
  27. CreateTime time.Time `description:"创建时间"`
  28. }
  29. type BaseFromTradeGuangzhouData struct {
  30. BaseFromTradeGuangzhouDataId int `orm:"column(base_from_trade_guangzhou_data_id);pk"`
  31. BaseFromTradeGuangzhouIndexId int `description:"指标id"`
  32. IndexCode string `description:"指标编码"`
  33. DataTime string `description:"数据日期"`
  34. Value float64 `description:"数据值"`
  35. QtySub float64 `description:"增减"`
  36. CreateTime time.Time `description:"创建日期"`
  37. ModifyTime time.Time `description:"修改日期"`
  38. }
  39. func GetBaseFromTradeGuangzhouData(indexCode, startDate, endDate string) (list []*BaseFromTradeGuangzhouData, err error) {
  40. o := orm.NewOrm()
  41. sql := `SELECT * FROM base_from_trade_guangzhou_data WHERE index_code=? AND create_time>=? AND create_time<=? `
  42. _, err = o.Raw(sql, indexCode, startDate, endDate).QueryRows(&list)
  43. return
  44. }
  45. // GetComTradeDataList 获取联合国商品贸易数据列表
  46. func GetBaseFromTradeGuangzhouDataList(startDate, endDate string, startSize, pageSize int) (total int, list []*BaseFromTradeGuangzhouData, err error) {
  47. o := orm.NewOrm()
  48. totalSql := `SELECT count(1) total FROM base_from_trade_guangzhou_data WHERE create_time>=? AND create_time<=? `
  49. err = o.Raw(totalSql, startDate, endDate).QueryRow(&total)
  50. if err != nil {
  51. return
  52. }
  53. sql := `SELECT * FROM base_from_trade_guangzhou_data WHERE create_time>=? AND create_time<=? ORDER BY base_from_trade_guangzhou_data_id ASC LIMIT ?,?`
  54. _, err = o.Raw(sql, startDate, endDate, startSize, pageSize).QueryRows(&list)
  55. return
  56. }
  57. // ComTradeIndexDataResp 分页列表响应体
  58. type BaseFromTradeGuangzhouDataResp struct {
  59. List []*BaseFromTradeGuangzhouData
  60. Paging *paging.PagingItem `description:"分页数据"`
  61. }
  62. func GetBaseFromTradeGuangzhouIndex(startDate, endDate string) (list []*BaseFromTradeGuangzhouIndex, err error) {
  63. o := orm.NewOrm()
  64. sql := `SELECT * FROM base_from_trade_guangzhou_index WHERE modify_time>=? AND modify_time<=? `
  65. _, err = o.Raw(sql, startDate, endDate).QueryRows(&list)
  66. return
  67. }