com_trade_index.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // ComTradeIndex 联合国商品贸易数据指标表
  8. type ComTradeIndex struct {
  9. ComTradeId int `orm:"column(com_trade_id);pk"`
  10. IndexCode string `description:"联合国商品贸易编码"`
  11. IndexName string `description:"联合国商品名称"`
  12. IndexNameCn string `description:"联合国商品名称(中文)"`
  13. UpdateTime time.Time `description:"数据最近更新时间"`
  14. CreateTime time.Time `description:"创建时间"`
  15. }
  16. // GetAllComTradeIndexList 获取指标数据列表
  17. func GetAllComTradeIndexList(startDate string) (list []*ComTradeIndex, err error) {
  18. o := orm.NewOrm()
  19. sql := `SELECT * FROM com_trade_index WHERE create_time>=? ORDER BY com_trade_id DESC `
  20. _, err = o.Raw(sql, startDate).QueryRows(&list)
  21. return
  22. }
  23. func GetBaseFromComTradeCodeMappingAll(dateStr string) (list []*BaseFromEiaSteoIndex, err error) {
  24. o := orm.NewOrm()
  25. sql := `SELECT * FROM com_trade_index WHERE create_time>=?`
  26. _, err = o.Raw(sql, dateStr).QueryRows(&list)
  27. return
  28. }
  29. // AddBaseFromComTradeIndex 添加新的指标
  30. func AddBaseFromComTradeIndex(item *ComTradeIndex) (lastId int64, err error) {
  31. o := orm.NewOrm()
  32. lastId, err = o.Insert(item)
  33. return
  34. }
  35. // ComTradeCodeMapping 联合国商品贸易数据指标编码与分类编码的关系表
  36. type ComTradeCodeMapping struct {
  37. Code string `orm:"column(code);pk"`
  38. IndexCode string `description:"联合国商品贸易编码"`
  39. Type int `description:"1:价格;2:重量"`
  40. Name string `description:"指标名称"`
  41. CreateTime time.Time `description:"创建时间"`
  42. }
  43. // GetAllComTradeCodeMappingList 获取联合国商品贸易数据指标编码与分类编码的关系列表
  44. func GetAllComTradeCodeMappingList(startDate string) (list []*ComTradeCodeMapping, err error) {
  45. o := orm.NewOrm()
  46. sql := `SELECT * FROM com_trade_code_mapping WHERE create_time>=? ORDER BY create_time ASC `
  47. _, err = o.Raw(sql, startDate).QueryRows(&list)
  48. return
  49. }
  50. // AddBaseFromComTradeCodeMapping 添加联合国商品贸易数据指标编码与分类编码的关系
  51. func AddBaseFromComTradeCodeMapping(item *ComTradeCodeMapping) (lastId int64, err error) {
  52. o := orm.NewOrm()
  53. lastId, err = o.Insert(item)
  54. return
  55. }
  56. type ComTradeIndexMappingResp struct {
  57. Ret int
  58. Msg string
  59. ErrMsg string
  60. ErrCode string
  61. Data ComTradeIndexAndMappingResp
  62. }
  63. type ComTradeIndexAndMappingResp struct {
  64. IndexList []ComTradeIndex
  65. MappingList []ComTradeCodeMapping
  66. }
  67. type ComTradeIndexDataResp struct {
  68. Ret int
  69. Msg string
  70. ErrMsg string
  71. ErrCode string
  72. Data ComTradeIndexAndDataResp
  73. }
  74. // ComTradeIndexAndDataResp 指标数据结构体
  75. type ComTradeIndexAndDataResp struct {
  76. List []*ComTradeData
  77. Paging *paging.PagingItem `description:"分页数据"`
  78. }