master
huanghai 5 years ago
parent f5953f6201
commit 83d2801735

@ -23,8 +23,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/opesun/goquery"
"github.com/tidwall/gjson"
"io"
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"
"time"
@ -542,9 +544,25 @@ func wxShowImg(context *gin.Context) {
p, err := goquery.ParseUrl(url)
if err != nil {
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "imgSrc": "", "message": "获取微信图片发生异常!"})
return
} else {
imgSrc := p.Find("img").Attr("src")
imgSrc = `https://open.weixin.qq.com` + imgSrc
context.JSON(http.StatusOK, map[string]interface{}{"success": true, "imgSrc": imgSrc})
//下载文件到本地临时目录中
res, err := http.Get(imgSrc)
if err != nil {
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "imgSrc": "", "message": "获取微信图片发生异常!"})
return
}
//图片
pngFile := "/usr/local/dsMin/dsSso/Logs/" + CommonUtil.GetUUID() + ".png"
f, err := os.Create(pngFile)
if err != nil {
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "imgSrc": "", "message": "获取微信图片发生异常!"})
return
}
io.Copy(f, res.Body)
//提供图片
context.File(pngFile)
}
}

@ -6,6 +6,7 @@ import (
"dsSso/Utils/IdCardUtil"
"errors"
"fmt"
uuid "github.com/satori/go.uuid"
"log"
"net"
"net/http"
@ -290,4 +291,13 @@ func CheckPasswordLevel(ps string) error {
return fmt.Errorf("password need symbol :%v", err)
}
return nil
}
}
/**
UUID
2020-02-03
*/
func GetUUID() string {
u2 := strings.ToUpper(uuid.NewV4().String())
return u2
}

Loading…
Cancel
Save