trade_analysis.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package trade_analysis
  2. import (
  3. "eta/eta_api/controllers"
  4. "eta/eta_api/models"
  5. trade_analysisModel "eta/eta_api/models/data_manage/trade_analysis"
  6. "eta/eta_api/services/data/trade_analysis"
  7. )
  8. // TradeAnalysisController 供应分析
  9. type TradeAnalysisController struct {
  10. controllers.BaseAuthController
  11. }
  12. // GetClassifyName
  13. // @Title 获取交易所合约列表
  14. // @Description 获取交易所合约列表
  15. // @Param request body saModel.SaCompareSaveReq true "type json string"
  16. // @Success 200 {object} trade_analysis.TradeClassifyNameListSort
  17. // @router /classify [get]
  18. func (c *TradeAnalysisController) GetClassifyName() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. if br.ErrMsg == "" {
  22. br.IsSendEmail = false
  23. }
  24. c.Data["json"] = br
  25. c.ServeJSON()
  26. }()
  27. //userinfo := userService.GetInfoByClaims(c)
  28. list, err, errMsg := trade_analysis.GetClassifyName()
  29. if err != nil {
  30. br.Msg = errMsg
  31. br.ErrMsg = "获取失败, ErrMsg: " + err.Error()
  32. return
  33. }
  34. br.Data = list
  35. br.Ret = 200
  36. br.Success = true
  37. br.Msg = "获取成功"
  38. }
  39. // GetPositionTop
  40. // @Title 获取合约榜单详情
  41. // @Description 获取合约榜单详情
  42. // @Param Exchange query string false "交易所"
  43. // @Param ClassifyName query string false "分类名称"
  44. // @Param ClassifyType query string false "具体合约名称"
  45. // @Param DataTime query string false "请求日期,如果为空,则返回最新的榜单日期"
  46. // @Success 200 {object} trade_analysis.GetPositionTopResp
  47. // @Success 200 Ret=200 操作成功
  48. // @router /top [get]
  49. func (c *TradeAnalysisController) GetPositionTop() {
  50. br := new(models.BaseResponse).Init()
  51. defer func() {
  52. if br.ErrMsg == "" {
  53. br.IsSendEmail = false
  54. }
  55. c.Data["json"] = br
  56. c.ServeJSON()
  57. }()
  58. req := trade_analysisModel.GetPositionTopReq{
  59. Exchange: c.GetString("Exchange"),
  60. ClassifyName: c.GetString("ClassifyName"),
  61. ClassifyType: c.GetString("ClassifyType"),
  62. DataTime: c.GetString("DataTime"),
  63. }
  64. if req.ClassifyName == "" {
  65. br.Msg = "请输入分类名称"
  66. br.IsSendEmail = false
  67. return
  68. }
  69. if req.ClassifyType == "" {
  70. br.Msg = "请输入合约名称"
  71. br.IsSendEmail = false
  72. return
  73. }
  74. list, err, errMsg := trade_analysis.GetPositionTopDetail(req)
  75. if err != nil {
  76. br.Msg = errMsg
  77. br.ErrMsg = err.Error()
  78. return
  79. }
  80. br.Data = list
  81. br.Ret = 200
  82. br.Success = true
  83. return
  84. }