report.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package controllers
  2. import (
  3. "eta/eta_mini_api/models"
  4. "eta/eta_mini_api/services"
  5. )
  6. type ReportController struct {
  7. BaseAuthController
  8. }
  9. // @Title 日评详情
  10. // @Description 日评详情接口
  11. // @Param ReportId query int true "报告id"
  12. // @Success 200 {object} models.ReportDetailResp
  13. // @router /detail [get]
  14. func (this *ReportController) Detail() {
  15. br := new(models.BaseResponse).Init()
  16. defer func() {
  17. this.Data["json"] = br
  18. this.ServeJSON()
  19. }()
  20. reportId, _ := this.GetInt("ReportId")
  21. if reportId <= 0 {
  22. br.Msg = "报告不存在"
  23. return
  24. }
  25. result, err := services.GetReportDetail(reportId)
  26. if err != nil {
  27. br.Msg = "查询报告详情失败"
  28. br.ErrMsg = "查询报告失败,系统异常,Err:" + err.Error()
  29. return
  30. }
  31. if result.Ret != 200 {
  32. br.Msg = "查询报告详情失败"
  33. br.ErrMsg = result.ErrMsg
  34. return
  35. }
  36. br.Msg = "查询成功"
  37. br.Success = true
  38. br.Ret = 200
  39. br.Data = result
  40. }
  41. // @Title 研报列表
  42. // @Description 研报列表
  43. // @Param ReportId query int true "报告id"
  44. // @Param chartPermissionId query int true "品种ID"
  45. // @Param Level query int true "品种层级"
  46. // @Param PageSize query int true "每页数据条数"
  47. // @Param CurrentIndex query int true "当前页页码,从1开始"
  48. // @Success 200 {object} models.ReportDetailResp
  49. // @router /list [get]
  50. func (this *ReportController) List() {
  51. br := new(models.BaseResponse).Init()
  52. defer func() {
  53. this.Data["json"] = br
  54. this.ServeJSON()
  55. }()
  56. pageSize, _ := this.GetInt("PageSize")
  57. currentIndex, _ := this.GetInt("CurrentIndex")
  58. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  59. level, _ := this.GetInt("Level")
  60. reports, err := services.GetReportList(chartPermissionId, level, currentIndex, pageSize)
  61. if err != nil {
  62. br.Msg = "研报列表查询失败"
  63. br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
  64. return
  65. }
  66. if reports.Ret != 200 {
  67. br.Msg = "研报列表查询失败"
  68. br.ErrMsg = reports.ErrMsg
  69. return
  70. }
  71. br.Data = reports.Data
  72. br.Msg = "查询成功"
  73. br.Ret = 200
  74. br.Success = true
  75. }
  76. // @Title 研报列表
  77. // @Description 研报列表
  78. // @Param ReportId query int true "报告id"
  79. // @Param chartPermissionId query int true "品种ID"
  80. // @Param PageSize query int true "每页数据条数"
  81. // @Param CurrentIndex query int true "当前页页码,从1开始"
  82. // @Success 200 {object} models.ReportDetailResp
  83. // @router /daily/list [get]
  84. func (this *ReportController) DailyList() {
  85. br := new(models.BaseResponse).Init()
  86. defer func() {
  87. this.Data["json"] = br
  88. this.ServeJSON()
  89. }()
  90. pageSize, _ := this.GetInt("PageSize")
  91. currentIndex, _ := this.GetInt("CurrentIndex")
  92. reports, err := services.GetReportDailyList(currentIndex, pageSize)
  93. if err != nil {
  94. br.Msg = "研报列表查询失败"
  95. br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
  96. return
  97. }
  98. br.Data = reports.Data
  99. br.Msg = "查询成功"
  100. br.Ret = 200
  101. br.Success = true
  102. }