report.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. count, err := models.GetMyReportCountByUserIdAndReportId(user.UserId, reportId)
  39. if err != nil {
  40. br.Msg = "查询收藏数量失败"
  41. br.ErrMsg = "查询收藏数量失败,Err:" + err.Error()
  42. return
  43. }
  44. if count > 0 {
  45. result.Data.IsCollect = true
  46. } else {
  47. result.Data.IsCollect = false
  48. }
  49. br.Msg = "查询成功"
  50. br.Success = true
  51. br.Ret = 200
  52. br.Data = result.Data
  53. }
  54. // @Title 研报列表
  55. // @Description 研报列表
  56. // @Param ChartPermissionId query int true "品种ID"
  57. // @Param Level query int true "品种层级"
  58. // @Param PageSize query int true "每页数据条数"
  59. // @Param CurrentIndex query int true "当前页页码,从1开始"
  60. // @Param RangeType query string true "范围类型,1-一天内,2-一周内,3-半年内"
  61. // @Success 200 {object} response.ReportList
  62. // @router /list [get]
  63. func (this *ReportController) List() {
  64. br := new(models.BaseResponse).Init()
  65. defer func() {
  66. this.Data["json"] = br
  67. this.ServeJSON()
  68. }()
  69. pageSize, _ := this.GetInt("PageSize")
  70. currentIndex, _ := this.GetInt("CurrentIndex")
  71. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  72. level, _ := this.GetInt("Level")
  73. rangeType, _ := this.GetInt("RangeType")
  74. reports, err := services.GetReportList(chartPermissionId, level, rangeType, currentIndex, pageSize)
  75. if err != nil {
  76. br.Msg = "研报列表查询失败"
  77. br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
  78. return
  79. }
  80. if reports.Ret != 200 {
  81. br.Msg = reports.Msg
  82. br.ErrMsg = reports.ErrMsg
  83. return
  84. }
  85. br.Data = reports.Data
  86. br.Msg = "查询成功"
  87. br.Ret = 200
  88. br.Success = true
  89. }
  90. // @Title 研报列表
  91. // @Description 研报列表
  92. // @Param ReportId query int true "报告id"
  93. // @Param chartPermissionId query int true "品种ID"
  94. // @Param PageSize query int true "每页数据条数"
  95. // @Param CurrentIndex query int true "当前页页码,从1开始"
  96. // @Success 200 {object} models.ReportDetailResp
  97. // @router /daily/list [get]
  98. func (this *ReportController) DailyList() {
  99. br := new(models.BaseResponse).Init()
  100. defer func() {
  101. this.Data["json"] = br
  102. this.ServeJSON()
  103. }()
  104. pageSize, _ := this.GetInt("PageSize")
  105. currentIndex, _ := this.GetInt("CurrentIndex")
  106. if pageSize <= 0 {
  107. pageSize = 3
  108. }
  109. reports, err := services.GetReportDailyList(currentIndex, pageSize)
  110. if err != nil {
  111. br.Msg = "研报列表查询失败"
  112. br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
  113. return
  114. }
  115. br.Data = reports.Data
  116. br.Msg = "查询成功"
  117. br.Ret = 200
  118. br.Success = true
  119. }
  120. // @Title 研报列表
  121. // @Description 研报列表
  122. // @Param ReportId query int true "报告id"
  123. // @Param chartPermissionId query int true "品种ID"
  124. // @Param PageSize query int true "每页数据条数"
  125. // @Param CurrentIndex query int true "当前页页码,从1开始"
  126. // @Success 200 {object} models.ReportDetailResp
  127. // @router /search [get]
  128. func (this *ReportController) Search() {
  129. br := new(models.BaseResponse).Init()
  130. defer func() {
  131. this.Data["json"] = br
  132. this.ServeJSON()
  133. }()
  134. keyWord := this.GetString("KeyWord")
  135. pageSize, _ := this.GetInt("PageSize")
  136. currentIndex, _ := this.GetInt("CurrentIndex")
  137. if pageSize <= 0 {
  138. pageSize = utils.PageSize30
  139. }
  140. if keyWord == "" {
  141. br.Msg = "请输入关键字"
  142. return
  143. }
  144. reports, err := services.SearchReport(keyWord, currentIndex, pageSize)
  145. if err != nil {
  146. br.Msg = "研报列表查询失败"
  147. br.ErrMsg = "研报列表查询失败,系统异常,Err:" + err.Error()
  148. return
  149. }
  150. br.Data = reports.Data
  151. br.Msg = "查询成功"
  152. br.Ret = 200
  153. br.Success = true
  154. }