com_trade_data.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package data_manage
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. // ComTradeData 联合国商品贸易数据表
  8. type ComTradeData struct {
  9. ComTradeDataId int `orm:"column(com_trade_data_id);pk"`
  10. ComTradeId int `description:"指标id"`
  11. IndexCode string `description:"联合国商品贸易编码"`
  12. Flow string `description:"贸易流向:X(Export:出口);M(Import:进口)"`
  13. ReporterCode int `description:"出口国id"`
  14. ReporterName string `description:"出口国名称"`
  15. PartnerCode int `description:"进口国id"`
  16. PartnerName string `description:"进口国名称"`
  17. Partner2Code int `description:"第二进口国id"`
  18. Partner2Name string `description:"第二进口国名称"`
  19. DateType int `description:"日期类型,1:年度,2:月度"`
  20. DataTime string `description:"数据日期"`
  21. IndexTradeCode string `description:"离岸价编码"`
  22. TradeValue float64 `description:"离岸价(美元)"`
  23. IndexNetWeightCode string `description:"净重编码"`
  24. NetWeightValue float64 `description:"净重/公斤"`
  25. ModifyTime time.Time `description:"最新更新时间"`
  26. CreateTime time.Time `description:"创建时间"`
  27. }
  28. // ComTradeDataListItem 联合国商品贸易数据列表数据
  29. type ComTradeDataListItem struct {
  30. ComTradeDataId int `orm:"column(com_trade_data_id);pk"`
  31. ComTradeId int `description:"指标id"`
  32. IndexCode string `description:"联合国商品贸易编码"`
  33. IndexNameCn string `description:"联合国商品贸易名称(中文)"`
  34. Flow string `description:"贸易流向:X(Export:出口);M(Import:进口)"`
  35. ReporterCode int `description:"出口国id"`
  36. ReporterName string `description:"出口国名称"`
  37. PartnerCode int `description:"进口国id"`
  38. PartnerName string `description:"进口国名称"`
  39. Partner2Code int `description:"第二进口国id"`
  40. Partner2Name string `description:"第二进口国名称"`
  41. DateType int `description:"日期类型,1:年度,2:月度"`
  42. DataTime time.Time `description:"数据日期" json:"-"`
  43. Date string `description:"数据年月份"`
  44. IndexTradeCode string `description:"离岸价编码"`
  45. TradeValue float64 `description:"离岸价(美元)"`
  46. IndexNetWeightCode string `description:"净重编码"`
  47. NetWeightValue float64 `description:"净重/公斤"`
  48. ModifyTime time.Time `description:"最新更新时间"`
  49. CreateTime time.Time `description:"创建时间"`
  50. }
  51. // ComTradeDataListResp 联合国商品贸易列表数据返回
  52. type ComTradeDataListResp struct {
  53. Paging *paging.PagingItem
  54. List []*ComTradeDataListItem
  55. LastUpdateTime string
  56. }
  57. // GetComTradeListCount 获取指标数据汇总数
  58. func GetComTradeListCount(condition string, pars []interface{}) (count int, err error) {
  59. o := orm.NewOrmUsingDB("data")
  60. sql := `SELECT COUNT(1) AS count FROM com_trade_data WHERE 1=1 `
  61. if condition != "" {
  62. sql += condition
  63. }
  64. err = o.Raw(sql, pars).QueryRow(&count)
  65. return
  66. }
  67. // GetComTradeList 获取指标数据列表
  68. func GetComTradeList(condition string, pars []interface{}, startSize, pageSize int, orderBy string) (list []*ComTradeDataListItem, err error) {
  69. o := orm.NewOrmUsingDB("data")
  70. sql := `SELECT * FROM com_trade_data WHERE 1=1 `
  71. if condition != "" {
  72. sql += condition
  73. }
  74. sql += ` ORDER BY ` + orderBy
  75. sql += ` limit ?,? `
  76. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  77. return
  78. }