package controllers import ( "eta/eta_report/models" "html" ) // ReportShareController 报告分享 type ReportShareController struct { BaseCommonController } // Detail // @Title 日评详情 // @Description 日评详情接口 // @Param ReportCode query string true "报告唯一编码" // @Success 200 {object} models.ReportShareDetailResp // @router /share/detail [get] func (this *ReportShareController) Detail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() reportCode := this.GetString("ReportCode") if reportCode == "" { br.Msg = "参数错误" br.ErrMsg = "参数错误,reportCode 为空" return } report, err := models.GetReportByCode(reportCode) if err != nil { br.Msg = "该报告已删除" br.ErrMsg = "获取报告详情失败,Err:" + err.Error() return } report.ContentSub = html.UnescapeString(report.ContentSub) report.Content = html.UnescapeString(report.Content) report.ContentStruct = html.UnescapeString(report.ContentStruct) if report.HeadResourceId > 0 { headResource, err := models.GetResourceItemById(report.HeadResourceId) if err != nil { br.Msg = "操作失败" br.ErrMsg = "获取资源库版头失败, Err: " + err.Error() return } report.HeadImg = headResource.ImgUrl report.HeadStyle = headResource.Style } if report.EndResourceId > 0 { endResource, err := models.GetResourceItemById(report.EndResourceId) if err != nil { br.Msg = "操作失败" br.ErrMsg = "获取资源库版头失败, Err: " + err.Error() return } report.EndImg = endResource.ImgUrl report.EndStyle = endResource.Style } resp := new(models.ReportShareDetailResp) // 免责声明 conf, e := models.GetBusinessConf() if e != nil { br.Msg = "获取失败" br.ErrMsg = "获取免责声明失败, Err: " + e.Error() return } if conf[models.BusinessConfDisclaimer] != "" { resp.Disclaimer = conf[models.BusinessConfDisclaimer] } // 研报分享抬头 if v, ok := conf[models.BusinessConfH5ShareName]; ok { resp.H5ShareName = v } if v, ok := conf[models.BusinessConfH5ReportShareImg]; ok { resp.H5ReportShareImg = v } if v, ok := conf[models.BusinessConfWatermarkChart]; ok { resp.WatermarkChart = v } if v, ok := conf[models.BusinessConfWatermarkReport]; ok { resp.WatermarkReport = v } // 报告Logo if v, ok := conf[models.BusinessConfReportCenterLogoShow]; ok { if v == `true` { if reportLogo, ok := conf[models.BusinessConfReportLogo]; ok { resp.ReportLogo = reportLogo } } } // 章节类型的报告 resp.Report = new(models.ReportItem) reportChapters := make([]*models.ReportChapter, 0) if report.HasChapter == 1 { // 获取章节内容 chapters, e := models.GetPublishedChapterListByReportId(report.Id) if e != nil { br.Msg = "获取失败" br.ErrMsg = "获取章节列表失败, Err: " + e.Error() return } if len(chapters) > 0 { for _, chapter := range chapters { chapter.Content = html.UnescapeString(chapter.Content) chapter.ContentSub = html.UnescapeString(chapter.ContentSub) reportChapters = append(reportChapters, chapter) } } //report.Abstract = report.Title } // 更新pv if e = models.UpdateReportPv(report.Id); e != nil { br.Msg = "获取失败" br.ErrMsg = "更新报告pv失败, Err: " + e.Error() return } resp.Report.Report = report resp.Report.ChapterList = reportChapters br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // OutSideReportDetail // @Title 日评详情 // @Description 日评详情接口 // @Param ReportCode query string true "报告唯一编码" // @Success 200 {object} models.ReportShareDetailResp // @router /share/outside/report/detail [get] func (this *ReportShareController) OutSideReportDetail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() reportCode := this.GetString("ReportCode") if reportCode == "" { br.Msg = "参数错误" br.ErrMsg = "参数错误,reportCode 为空" return } report, err := models.GetOutsideReportByReportCode(reportCode) if err != nil { br.Msg = "该报告已删除" br.ErrMsg = "获取报告详情失败,Err:" + err.Error() return } report.Content = html.UnescapeString(report.Content) attachmentList, err := models.GetOutsideReportAttachmentListByReportId(report.OutsideReportId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取附件列表失败, Err: " + err.Error() return } outsideReportBO := models.OutsideReportBO{ OutsideReportId: report.OutsideReportId, Source: report.Source, Title: report.Title, Abstract: report.Abstract, ClassifyId: report.ClassifyId, ClassifyName: report.ClassifyName, Content: report.Content, SysUserId: report.SysUserId, SysUserName: report.SysUserName, AttachmentList: attachmentList, } resp := new(models.OutsideReportResp) // 免责声明 conf, e := models.GetBusinessConf() if e != nil { br.Msg = "获取失败" br.ErrMsg = "获取免责声明失败, Err: " + e.Error() return } if conf[models.BusinessConfDisclaimer] != "" { resp.Disclaimer = conf[models.BusinessConfDisclaimer] } // 研报分享抬头 if v, ok := conf[models.BusinessConfH5ShareName]; ok { resp.H5ShareName = v } if v, ok := conf[models.BusinessConfH5ReportShareImg]; ok { resp.H5ReportShareImg = v } if v, ok := conf[models.BusinessConfWatermarkChart]; ok { resp.WatermarkChart = v } if v, ok := conf[models.BusinessConfWatermarkReport]; ok { resp.WatermarkReport = v } // 报告Logo if v, ok := conf[models.BusinessConfReportCenterLogoShow]; ok { if v == `true` { if reportLogo, ok := conf[models.BusinessConfReportLogo]; ok { resp.ReportLogo = reportLogo } } } resp.OutsideReportBO = &outsideReportBO br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp }