|
@@ -1,6 +1,15 @@
|
|
|
package controllers
|
|
|
|
|
|
import (
|
|
|
+ //"bufio"
|
|
|
+ //"io"
|
|
|
+ //"path"
|
|
|
+ //"rdluck_tools/http"
|
|
|
+
|
|
|
+ "bufio"
|
|
|
+ "io"
|
|
|
+
|
|
|
+ //"bufio"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/medivhzhan/weapp/v2"
|
|
@@ -8,8 +17,17 @@ import (
|
|
|
"hongze/hongze_cygx/services"
|
|
|
"hongze/hongze_cygx/utils"
|
|
|
"html"
|
|
|
- "os"
|
|
|
"rdluck_tools/http"
|
|
|
+
|
|
|
+ //"rdluck_tools/http"
|
|
|
+
|
|
|
+ //"io"
|
|
|
+ nhttp "net/http"
|
|
|
+ "os"
|
|
|
+ //"rdluck_tools/http"
|
|
|
+
|
|
|
+ //"path"
|
|
|
+ //"rdluck_tools/http"
|
|
|
"regexp"
|
|
|
"strconv"
|
|
|
"strings"
|
|
@@ -710,14 +728,13 @@ func (this *ArticleController) AskAdd() {
|
|
|
br.ErrMsg = "提交失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- companyItem, err := models.GetCompanyDetailById(user.CompanyId)
|
|
|
+ companyItem, err := models.GetSellerDetailAllByCompanyId(user.CompanyId)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取信息失败"
|
|
|
br.ErrMsg = "获取所属销售信息失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
var mobile string
|
|
|
- companyItem.Mobile = "123"
|
|
|
if utils.WxMsgTemplateIdAskMsgMobile == "" {
|
|
|
mobile = utils.WxMsgTemplateIdAskMsgMobileAll + "," + companyItem.Mobile
|
|
|
} else {
|
|
@@ -788,19 +805,40 @@ func (this *ArticleController) Pdfwatermark() {
|
|
|
dataMap["Mobile"] = mobile
|
|
|
//dataMap["Name"] = user.RealName
|
|
|
dataMap["Name"] = ""
|
|
|
+ pdfPath := "static/"
|
|
|
+ pdfUrl := fileLink
|
|
|
+ fileName := utils.GetRandStringNoSpecialChar(28) + ".pdf"
|
|
|
+ res, err := nhttp.Get(pdfUrl)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("A error occurred!")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer res.Body.Close()
|
|
|
+ // 获得get请求响应的reader对象
|
|
|
+ reader := bufio.NewReaderSize(res.Body, 32*1024)
|
|
|
+ file, err := os.Create(pdfPath + fileName)
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ //获得文件的writer对象
|
|
|
+ writer := bufio.NewWriter(file)
|
|
|
+ written, _ := io.Copy(writer, reader)
|
|
|
+ fmt.Printf("Total length: %d", written)
|
|
|
+ str, _ := os.Getwd()
|
|
|
+ fileLink = str + "/" + pdfPath + fileName
|
|
|
dataMap["FileLink"] = fileLink
|
|
|
postUrl := "http://127.0.0.1:5007/pdfwatermark/" //
|
|
|
fmt.Println("postUrl:", postUrl)
|
|
|
postData, err := json.Marshal(dataMap)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取postData数据失败"
|
|
|
+ br.Msg = "下载失败"
|
|
|
br.ErrMsg = "解析,Marshal,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
fmt.Println("publish ppt param:", string(postData))
|
|
|
result, err := http.Post(postUrl, string(postData))
|
|
|
if err != nil {
|
|
|
- br.Msg = "发布失败"
|
|
|
+ br.Msg = "下载失败"
|
|
|
br.ErrMsg = "Marshal,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
@@ -808,26 +846,25 @@ func (this *ArticleController) Pdfwatermark() {
|
|
|
var pdfResult PublishPdfResult
|
|
|
err = json.Unmarshal(result, &pdfResult)
|
|
|
if err != nil {
|
|
|
- br.Msg = "获取数据失败"
|
|
|
+ br.Msg = "下载失败"
|
|
|
br.ErrMsg = "Unmarshal,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
+ //fmt.Println(pdfResult)
|
|
|
resp := new(models.ArticleDetailFileLink)
|
|
|
filePathName := strings.TrimLeft(pdfResult.FilePath, ".")
|
|
|
- filePathOldName := strings.TrimLeft(pdfResult.FileOldPath, ".")
|
|
|
+ //filePathOldName := strings.TrimLeft(pdfResult.FileOldPath, ".")
|
|
|
filePath := pdfResult.Pdfpath + filePathName
|
|
|
- filePathOld := pdfResult.Pdfpath + filePathOldName
|
|
|
- fmt.Println(filePath)
|
|
|
- fmt.Println(filePathOld)
|
|
|
+ //filePathOld := pdfResult.Pdfpath + filePathOldName
|
|
|
randStr := utils.GetRandStringNoSpecialChar(28)
|
|
|
- fileName := randStr + ".pdf"
|
|
|
+ fileName = randStr + ".pdf"
|
|
|
hzUploadDir := "static/pdf/"
|
|
|
savePath := hzUploadDir + time.Now().Format("200601/20060102/")
|
|
|
savePath += fileName
|
|
|
//上传到阿里云
|
|
|
- err = services.UploadFileToAliyun(fileName, filePath, savePath)
|
|
|
+ err = services.UploadFileToAliyun(fileName, fileLink, savePath)
|
|
|
if err != nil {
|
|
|
- br.Msg = "文件上传失败"
|
|
|
+ br.Msg = "下载失败"
|
|
|
br.ErrMsg = "文件上传失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
@@ -837,7 +874,7 @@ func (this *ArticleController) Pdfwatermark() {
|
|
|
resourceUrl := fileHost + savePath
|
|
|
defer func() {
|
|
|
os.Remove(filePath)
|
|
|
- os.Remove(filePathOld)
|
|
|
+ os.Remove(fileLink)
|
|
|
}()
|
|
|
resp.FileLink = resourceUrl
|
|
|
br.Ret = 200
|