|
@@ -391,17 +391,33 @@ func fillContent2HtmlV2(source, pars, sunCodeUrl string, height float64, ybPoste
|
|
}
|
|
}
|
|
|
|
|
|
// GetDynamicShareImg 生成动态分享图
|
|
// GetDynamicShareImg 生成动态分享图
|
|
-func GetDynamicShareImg(source, pars string) (imgUrl string, err error) {
|
|
|
|
|
|
+func GetDynamicShareImg(source, pars string, reportId, reportChapterId int, version string) (imgUrl string, err error) {
|
|
if source == "" {
|
|
if source == "" {
|
|
err = errors.New("图片来源有误")
|
|
err = errors.New("图片来源有误")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // 报告章节详情无需重复生成
|
|
|
|
+ var path string
|
|
|
|
+ if reportId > 0 {
|
|
|
|
+ path = fmt.Sprintf("reportDetailCover?ReportId=%d&ReportChapterId=%d", reportId, reportChapterId)
|
|
|
|
+ poster, e := yb_poster_resource.GetPosterByCondition(path, "poster", version)
|
|
|
|
+ if e != nil && e != utils.ErrNoRow {
|
|
|
|
+ err = fmt.Errorf("获取报告已生成海报失败, %e", e)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if poster != nil && poster.ImgURL != "" {
|
|
|
|
+ imgUrl = poster.ImgURL
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 生成海报
|
|
imgConfig, e := yb_poster_config.GetBySource(source)
|
|
imgConfig, e := yb_poster_config.GetBySource(source)
|
|
if e != nil {
|
|
if e != nil {
|
|
err = errors.New("获取图片配置失败")
|
|
err = errors.New("获取图片配置失败")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- // 填充html内容
|
|
|
|
content, newHeight, e := fillContent2HtmlV2(source, pars, "", imgConfig.Hight, *imgConfig)
|
|
content, newHeight, e := fillContent2HtmlV2(source, pars, "", imgConfig.Hight, *imgConfig)
|
|
if e != nil {
|
|
if e != nil {
|
|
err = errors.New("html内容有误")
|
|
err = errors.New("html内容有误")
|
|
@@ -421,6 +437,18 @@ func GetDynamicShareImg(source, pars string) (imgUrl string, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
imgUrl = res.Data
|
|
imgUrl = res.Data
|
|
|
|
+
|
|
|
|
+ // 报告详情-记录海报信息
|
|
|
|
+ if reportId > 0 {
|
|
|
|
+ newPoster := &yb_poster_resource.YbPosterResource{
|
|
|
|
+ Path: path,
|
|
|
|
+ ImgURL: imgUrl,
|
|
|
|
+ Type: "poster",
|
|
|
|
+ Version: version,
|
|
|
|
+ CreateTime: time.Now(),
|
|
|
|
+ }
|
|
|
|
+ err = newPoster.Create()
|
|
|
|
+ }
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -496,4 +524,4 @@ finally:
|
|
cmd.Process.Kill()
|
|
cmd.Process.Kill()
|
|
}()
|
|
}()
|
|
return
|
|
return
|
|
-}
|
|
|
|
|
|
+}
|