master
huanghai 5 years ago
parent f5953f6201
commit 83d2801735

@ -23,8 +23,10 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/opesun/goquery" "github.com/opesun/goquery"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -542,9 +544,25 @@ func wxShowImg(context *gin.Context) {
p, err := goquery.ParseUrl(url) p, err := goquery.ParseUrl(url)
if err != nil { if err != nil {
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "imgSrc": "", "message": "获取微信图片发生异常!"}) context.JSON(http.StatusOK, map[string]interface{}{"success": false, "imgSrc": "", "message": "获取微信图片发生异常!"})
return
} else { } else {
imgSrc := p.Find("img").Attr("src") imgSrc := p.Find("img").Attr("src")
imgSrc = `https://open.weixin.qq.com` + imgSrc 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" "dsSso/Utils/IdCardUtil"
"errors" "errors"
"fmt" "fmt"
uuid "github.com/satori/go.uuid"
"log" "log"
"net" "net"
"net/http" "net/http"
@ -290,4 +291,13 @@ func CheckPasswordLevel(ps string) error {
return fmt.Errorf("password need symbol :%v", err) return fmt.Errorf("password need symbol :%v", err)
} }
return nil return nil
} }
/**
UUID
2020-02-03
*/
func GetUUID() string {
u2 := strings.ToUpper(uuid.NewV4().String())
return u2
}

Loading…
Cancel
Save