浏览代码

PDF 文件格式无法打水印的时候,输出原文件

xingzai 2 年之前
父节点
当前提交
be4308d89f
共有 1 个文件被更改,包括 9 次插入4 次删除
  1. 9 4
      controllers/article.go

+ 9 - 4
controllers/article.go

@@ -887,7 +887,7 @@ func (this *ArticleController) Pdfwatermark() {
 		br.ErrMsg = "下载失败,下载过于频繁:mobile" + user.Mobile
 		return
 	}
-
+	resp := new(models.ArticleDetailFileLink)
 	detail := new(models.ArticleDetail)
 	detail, err = models.GetArticleDetailById(articleId)
 	if err != nil {
@@ -955,11 +955,16 @@ func (this *ArticleController) Pdfwatermark() {
 	}
 	err = api.AddWatermarksFile(oldFile, newFile, nil, wm, nil)
 	if err != nil {
-		br.Msg = "下载失败"
-		br.ErrMsg = "生成水印PDF失败,Err:" + err.Error()
+		//br.Msg = "下载失败"
+		//br.ErrMsg = "生成水印PDF失败,Err:" + err.Error()
+		resp.FileLink = fileLink
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
 		return
 	}
-	resp := new(models.ArticleDetailFileLink)
+
 	randStr := utils.GetRandStringNoSpecialChar(28)
 	fileName := randStr + ".pdf"
 	savePath := uploadDir + time.Now().Format("200601/20060102/")