|
@@ -1,8 +1,11 @@
|
|
|
package controllers
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"eta/eta_report/models"
|
|
|
+ "fmt"
|
|
|
"html"
|
|
|
+ "strings"
|
|
|
)
|
|
|
|
|
|
// ReportShareController 报告分享
|
|
@@ -14,6 +17,7 @@ type ReportShareController struct {
|
|
|
// @Title 日评详情
|
|
|
// @Description 日评详情接口
|
|
|
// @Param ReportCode query string true "报告唯一编码"
|
|
|
+// @Param IsReplace query int false "是否报告转长图的场景:1-是"
|
|
|
// @Success 200 {object} models.ReportShareDetailResp
|
|
|
// @router /share/detail [get]
|
|
|
func (this *ReportShareController) Detail() {
|
|
@@ -24,6 +28,7 @@ func (this *ReportShareController) Detail() {
|
|
|
}()
|
|
|
|
|
|
reportCode := this.GetString("ReportCode")
|
|
|
+ isReplace, _ := this.GetInt("IsReplace", 0)
|
|
|
if reportCode == "" {
|
|
|
br.Msg = "参数错误"
|
|
|
br.ErrMsg = "参数错误,reportCode 为空"
|
|
@@ -69,6 +74,15 @@ func (this *ReportShareController) Detail() {
|
|
|
br.ErrMsg = "获取免责声明失败, Err: " + e.Error()
|
|
|
return
|
|
|
}
|
|
|
+ // 是否需要替换资源地址
|
|
|
+ var urlReplace models.Report2ImgReplace
|
|
|
+ if isReplace == 1 && conf[models.BusinessConfReport2ImgReplace] != "" {
|
|
|
+ if e := json.Unmarshal([]byte(conf[models.BusinessConfReport2ImgReplace]), &urlReplace); e != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.ErrMsg = fmt.Sprintf("获取报告替换配置失败, %v", e)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
if conf[models.BusinessConfDisclaimer] != "" {
|
|
|
resp.Disclaimer = conf[models.BusinessConfDisclaimer]
|
|
|
}
|
|
@@ -110,12 +124,36 @@ func (this *ReportShareController) Detail() {
|
|
|
for _, chapter := range chapters {
|
|
|
chapter.Content = html.UnescapeString(chapter.Content)
|
|
|
chapter.ContentSub = html.UnescapeString(chapter.ContentSub)
|
|
|
+ if urlReplace.IsReplace {
|
|
|
+ if urlReplace.OssUrlOrigin != "" {
|
|
|
+ chapter.Content = strings.ReplaceAll(chapter.Content, urlReplace.OssUrlOrigin, urlReplace.OssUrlNew)
|
|
|
+ chapter.ContentSub = strings.ReplaceAll(chapter.ContentSub, urlReplace.OssUrlOrigin, urlReplace.OssUrlNew)
|
|
|
+ }
|
|
|
+ if urlReplace.ChartUrlOrigin != "" {
|
|
|
+ chapter.Content = strings.ReplaceAll(chapter.Content, urlReplace.ChartUrlOrigin, urlReplace.ChartUrlNew)
|
|
|
+ chapter.ContentSub = strings.ReplaceAll(chapter.ContentSub, urlReplace.ChartUrlOrigin, urlReplace.ChartUrlNew)
|
|
|
+ }
|
|
|
+ }
|
|
|
reportChapters = append(reportChapters, chapter)
|
|
|
}
|
|
|
}
|
|
|
//report.Abstract = report.Title
|
|
|
}
|
|
|
|
|
|
+ // 替换地址
|
|
|
+ if urlReplace.IsReplace {
|
|
|
+ if urlReplace.OssUrlOrigin != "" {
|
|
|
+ resp.H5ReportShareImg = strings.ReplaceAll(resp.H5ReportShareImg, urlReplace.OssUrlOrigin, urlReplace.OssUrlNew)
|
|
|
+ resp.ReportLogo = strings.ReplaceAll(resp.ReportLogo, urlReplace.OssUrlOrigin, urlReplace.OssUrlNew)
|
|
|
+ report.Content = strings.ReplaceAll(report.Content, urlReplace.OssUrlOrigin, urlReplace.OssUrlNew)
|
|
|
+ report.ContentSub = strings.ReplaceAll(report.ContentSub, urlReplace.OssUrlOrigin, urlReplace.OssUrlNew)
|
|
|
+ }
|
|
|
+ if urlReplace.ChartUrlOrigin != "" {
|
|
|
+ report.Content = strings.ReplaceAll(report.Content, urlReplace.ChartUrlOrigin, urlReplace.ChartUrlNew)
|
|
|
+ report.ContentSub = strings.ReplaceAll(report.ContentSub, urlReplace.ChartUrlOrigin, urlReplace.ChartUrlNew)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 更新pv
|
|
|
if e = models.UpdateReportPv(report.Id); e != nil {
|
|
|
br.Msg = "获取失败"
|