com_trade_index.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package data_manage
  2. import (
  3. "eta/eta_task/global"
  4. "eta/eta_task/utils"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "time"
  7. )
  8. // ComTradeIndex 联合国商品贸易数据指标表
  9. type ComTradeIndex struct {
  10. ComTradeId int `gorm:"column:com_trade_id;primaryKey;autoIncrement"`
  11. IndexCode string `description:"联合国商品贸易编码"`
  12. IndexName string `description:"联合国商品名称"`
  13. IndexNameCn string `description:"联合国商品名称(中文)"`
  14. UpdateTime time.Time `description:"数据最近更新时间"`
  15. CreateTime time.Time `description:"创建时间"`
  16. }
  17. // GetAllComTradeIndexList 获取指标数据列表
  18. func GetAllComTradeIndexList(startDate string) (list []*ComTradeIndex, err error) {
  19. o := global.DbMap[utils.DbNameIndex]
  20. sql := `SELECT * FROM com_trade_index WHERE create_time>=? ORDER BY com_trade_id DESC `
  21. err = o.Raw(sql, startDate).Find(&list).Error
  22. return
  23. }
  24. func GetBaseFromComTradeCodeMappingAll(dateStr string) (list []*BaseFromEiaSteoIndex, err error) {
  25. o := global.DbMap[utils.DbNameIndex]
  26. sql := `SELECT * FROM com_trade_index WHERE create_time>=?`
  27. err = o.Raw(sql, dateStr).Find(&list).Error
  28. return
  29. }
  30. // AddBaseFromComTradeIndex 添加新的指标
  31. func AddBaseFromComTradeIndex(item *ComTradeIndex) (lastId int64, err error) {
  32. err = global.DbMap[utils.DbNameIndex].Create(item).Error
  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 := global.DbMap[utils.DbNameIndex]
  46. sql := `SELECT * FROM com_trade_code_mapping WHERE create_time>=? ORDER BY create_time ASC `
  47. err = o.Raw(sql, startDate).Find(&list).Error
  48. return
  49. }
  50. // AddBaseFromComTradeCodeMapping 添加联合国商品贸易数据指标编码与分类编码的关系
  51. func AddBaseFromComTradeCodeMapping(item *ComTradeCodeMapping) (lastId int64, err error) {
  52. err = global.DbMap[utils.DbNameIndex].Create(item).Error
  53. return
  54. }
  55. type ComTradeIndexMappingResp struct {
  56. Ret int
  57. Msg string
  58. ErrMsg string
  59. ErrCode string
  60. Data ComTradeIndexAndMappingResp
  61. }
  62. type ComTradeIndexAndMappingResp struct {
  63. IndexList []ComTradeIndex
  64. MappingList []ComTradeCodeMapping
  65. }
  66. type ComTradeIndexDataResp struct {
  67. Ret int
  68. Msg string
  69. ErrMsg string
  70. ErrCode string
  71. Data ComTradeIndexAndDataResp
  72. }
  73. // ComTradeIndexAndDataResp 指标数据结构体
  74. type ComTradeIndexAndDataResp struct {
  75. List []*ComTradeData
  76. Paging *paging.PagingItem `description:"分页数据"`
  77. }