report_pc.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package controllers
  2. import (
  3. "hongze/hongze_api/models"
  4. )
  5. // @Title 研报列表
  6. // @Description 研报列表接口
  7. // @Param ClassifyId query int true "分类id"
  8. // @Success 200 {object} models.ResearchReportListResp
  9. // @router /pc/research/report/list [get]
  10. func (this *ReportCommonController) ResearchReportList() {
  11. br := new(models.BaseResponse).Init()
  12. defer func() {
  13. this.Data["json"] = br
  14. this.ServeJSON()
  15. }()
  16. classifyId, _ := this.GetInt("ClassifyId")
  17. if classifyId <= 0 {
  18. br.Msg = "参数错误"
  19. br.ErrMsg = "参数错误,分类id小于等于0"
  20. return
  21. }
  22. list, err := models.GetResearchReportList(classifyId)
  23. if err != nil {
  24. br.Msg = "获取失败"
  25. br.ErrMsg = "获取失败,Err:" + err.Error()
  26. return
  27. }
  28. resp := new(models.ResearchReportListResp)
  29. resp.List = list
  30. br.Ret = 200
  31. br.Success = true
  32. br.Msg = "获取成功"
  33. br.Data = resp
  34. }
  35. // @Title 研报PC端搜索接口
  36. // @Param KeyWord query string true "搜索关键词"
  37. // @Success 200 {object} models.PcSearchReportListResp
  38. // @router /pc/search/report/list [get]
  39. func (this *ReportCommonController) PcSearchReportList() {
  40. // @Description 研报PC端搜索接口
  41. // @Param PageSize query int true "每页数据条数"
  42. // @Param CurrentIndex query int true "当前页页码,从1开始"
  43. br := new(models.BaseResponse).Init()
  44. defer func() {
  45. this.Data["json"] = br
  46. this.ServeJSON()
  47. }()
  48. keyWord := this.GetString("KeyWord")
  49. //pageSize, _ := this.GetInt("PageSize")
  50. //currentIndex, _ := this.GetInt("CurrentIndex")
  51. //classifyId, _ := this.GetInt("ClassifyId")
  52. //if classifyId <= 0 {
  53. // br.Msg = "参数错误"
  54. // br.ErrMsg = "参数错误,分类id小于等于0"
  55. // return
  56. //}
  57. //
  58. //page := paging.GetPaging(currentIndex, pageSize, 0)
  59. resp := new(models.PcSearchReportListResp)
  60. var condition string
  61. //var pars []interface{}
  62. if keyWord != "" {
  63. condition += ` AND (a.title LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') `
  64. } else {
  65. list := make([]*models.ReportList, 0)
  66. resp.List = list
  67. //resp.Paging = page
  68. br.Ret = 200
  69. br.Success = true
  70. br.Msg = "获取成功"
  71. br.Data = resp
  72. return
  73. }
  74. //var startSize int
  75. //if pageSize <= 0 {
  76. // pageSize = utils.PageSize20
  77. //}
  78. //if currentIndex <= 0 {
  79. // currentIndex = 1
  80. //}
  81. //startSize = utils.StartIndex(currentIndex, pageSize)
  82. //total, err := models.GetSearchReportListCount(condition)
  83. //if err != nil {
  84. // br.Msg = "获取数据失败"
  85. // br.ErrMsg = "获取数据失败,Err:" + err.Error()
  86. // return
  87. //}
  88. list, err := models.GetSearchReportList(condition)
  89. if err != nil {
  90. br.Msg = "获取失败"
  91. br.ErrMsg = "获取失败,Err:" + err.Error()
  92. return
  93. }
  94. listLen := len(list)
  95. for i := 0; i < listLen; i++ {
  96. item := list[i]
  97. if this.Token != "" {
  98. count, err := models.GetReportPermission(this.User.UserId, item.ClassifyNameSecond)
  99. if err != nil {
  100. br.Msg = "获取失败"
  101. br.ErrMsg = "判断报告是否拥有权限失败,Err:" + err.Error()
  102. return
  103. }
  104. if count > 0 {
  105. list[i].HasPermission = 1
  106. }
  107. }else{
  108. list[i].VideoUrl = ""
  109. list[i].VideoName = ""
  110. list[i].VideoPlaySeconds = ""
  111. list[i].VideoSize = ""
  112. }
  113. if item.ClassifyNameFirst == "权益研报" {
  114. list[i].TitleType = "图说逻辑"
  115. } else {
  116. list[i].TitleType = "FICC"
  117. }
  118. }
  119. //page = paging.GetPaging(currentIndex, pageSize, total)
  120. resp.List = list
  121. //resp.Paging = page
  122. br.Ret = 200
  123. br.Success = true
  124. br.Msg = "获取成功"
  125. br.Data = resp
  126. }