package controllers import ( "hongze/hongze_api/models" "html" ) //报告分享 type ReportShareController struct { BaseCommonController } // @Title 日评详情 // @Description 日评详情接口 // @Param ReportId query int true "报告id" // @Success 200 {object} models.ReportDetailResp // @router /share/detail [get] func (this *ReportShareController) Detail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() var status int var msg string reportId, err := this.GetInt("ReportId") if err != nil { br.Msg = "参数获取失败" br.ErrMsg = "参数获取失败,Err:" + err.Error() return } if reportId <= 0 { br.Msg = "参数错误" br.ErrMsg = "参数错误,报告id小于等于0" return } report, err := models.GetReportById(reportId) if err != nil { br.Msg = "获取报告详情失败" br.ErrMsg = "获取报告详情失败,Err:" + err.Error() return } if report == nil { status = 1 msg = "报告不存在" } report.ContentSub = html.UnescapeString(report.ContentSub) report.Content = html.UnescapeString(report.Content) resp := new(models.ReportDetailResp) resp.Status = status resp.Msg = msg resp.Report = report recommendList, err := models.GetRecommendList(reportId) if err != nil { br.Msg = "获取报告详情失败" br.ErrMsg = "获取报告推荐列表信息失败,Err:" + err.Error() return } recommendListLen := len(recommendList) for i := 0; i < recommendListLen; i++ { item := recommendList[i] recommendList[i].Content = html.UnescapeString(item.Content) recommendList[i].ContentSub = html.UnescapeString(item.ContentSub) } resp.RecommendList = recommendList br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp }