report.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package controllers
  2. import (
  3. "eta/eta_mini_api/models"
  4. "eta/eta_mini_api/services"
  5. "eta/eta_mini_api/utils"
  6. )
  7. type ReportController struct {
  8. BaseAuthController
  9. }
  10. // @Title 研报详情
  11. // @Description 研报详情接口
  12. // @Param ReportId query int true "报告id"
  13. // @Success 200 {object} models.ReportDetailResp
  14. // @router /detail [get]
  15. func (this *ReportController) Detail() {
  16. br := new(models.BaseResponse).Init()
  17. defer func() {
  18. this.Data["json"] = br
  19. this.ServeJSON()
  20. }()
  21. reportId, _ := this.GetInt("ReportId")
  22. if reportId <= 0 {
  23. br.Msg = "报告不存在"
  24. return
  25. }
  26. user := this.User
  27. result, err := services.GetReportDetail(reportId, user.UserId)
  28. if err != nil {
  29. br.Msg = "查询报告详情失败"
  30. br.ErrMsg = "查询报告失败,系统异常,Err:" + err.Error()
  31. return
  32. }
  33. if result.Ret == 403 {
  34. br.Msg = result.Msg
  35. br.ErrMsg = result.ErrMsg
  36. return
  37. }
  38. br.Msg = "查询成功"
  39. br.Success = true
  40. br.Ret = 200
  41. br.Data = result.Data
  42. }
  43. // @Title 研报列表
  44. // @Description 研报列表
  45. // @Param ChartPermissionId query int true "品种ID"
  46. // @Param Level query int true "品种层级"
  47. // @Param PageSize query int true "每页数据条数"
  48. // @Param CurrentIndex query int true "当前页页码,从1开始"
  49. // @Param RangeType query string true "范围类型,1-一天内,2-一周内,3-半年内"
  50. // @Success 200 {object} models.ReportDetailResp
  51. // @router /list [get]
  52. func (this *ReportController) List() {
  53. br := new(models.BaseResponse).Init()
  54. defer func() {
  55. this.Data["json"] = br
  56. this.ServeJSON()
  57. }()
  58. pageSize, _ := this.GetInt("PageSize")
  59. currentIndex, _ := this.GetInt("CurrentIndex")
  60. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  61. level, _ := this.GetInt("Level")
  62. rangeType, _ := this.GetInt("RangeType")
  63. reports, err := services.GetReportList(chartPermissionId, level, rangeType, currentIndex, pageSize)
  64. if err != nil {
  65. br.Msg = "研报列表查询失败"
  66. br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
  67. return
  68. }
  69. if reports.Ret != 200 {
  70. br.Msg = "研报列表查询失败"
  71. br.ErrMsg = reports.ErrMsg
  72. return
  73. }
  74. br.Data = reports.Data
  75. br.Msg = "查询成功"
  76. br.Ret = 200
  77. br.Success = true
  78. }
  79. // @Title 研报列表
  80. // @Description 研报列表
  81. // @Param ReportId query int true "报告id"
  82. // @Param chartPermissionId query int true "品种ID"
  83. // @Param PageSize query int true "每页数据条数"
  84. // @Param CurrentIndex query int true "当前页页码,从1开始"
  85. // @Success 200 {object} models.ReportDetailResp
  86. // @router /daily/list [get]
  87. func (this *ReportController) DailyList() {
  88. br := new(models.BaseResponse).Init()
  89. defer func() {
  90. this.Data["json"] = br
  91. this.ServeJSON()
  92. }()
  93. pageSize, _ := this.GetInt("PageSize")
  94. currentIndex, _ := this.GetInt("CurrentIndex")
  95. if pageSize <= 0 {
  96. pageSize = 3
  97. }
  98. reports, err := services.GetReportDailyList(currentIndex, pageSize)
  99. if err != nil {
  100. br.Msg = "研报列表查询失败"
  101. br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
  102. return
  103. }
  104. br.Data = reports.Data
  105. br.Msg = "查询成功"
  106. br.Ret = 200
  107. br.Success = true
  108. }
  109. // @Title 研报列表
  110. // @Description 研报列表
  111. // @Param ReportId query int true "报告id"
  112. // @Param chartPermissionId query int true "品种ID"
  113. // @Param PageSize query int true "每页数据条数"
  114. // @Param CurrentIndex query int true "当前页页码,从1开始"
  115. // @Success 200 {object} models.ReportDetailResp
  116. // @router /search [get]
  117. func (this *ReportController) Search() {
  118. br := new(models.BaseResponse).Init()
  119. defer func() {
  120. this.Data["json"] = br
  121. this.ServeJSON()
  122. }()
  123. keyWord := this.GetString("KeyWord")
  124. pageSize, _ := this.GetInt("PageSize")
  125. currentIndex, _ := this.GetInt("CurrentIndex")
  126. if pageSize <= 0 {
  127. pageSize = utils.PageSize30
  128. }
  129. if keyWord == "" {
  130. br.Msg = "请输入关键字"
  131. return
  132. }
  133. reports, err := services.SearchReport(keyWord, currentIndex, pageSize)
  134. if err != nil {
  135. br.Msg = "研报列表查询失败"
  136. br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
  137. return
  138. }
  139. br.Data = reports.Data
  140. br.Msg = "查询成功"
  141. br.Ret = 200
  142. br.Success = true
  143. }