master
huanghai 5 years ago
parent 4840fea102
commit 03df17ee8d

@ -21,12 +21,9 @@ import (
"fmt"
"github.com/dchest/captcha"
"github.com/gin-gonic/gin"
"github.com/opesun/goquery"
"github.com/tidwall/gjson"
"io"
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"
"time"
@ -55,8 +52,6 @@ func Routers(r *gin.RouterGroup) {
r.GET("/checkOpenId", checkOpenId)
//绑定用户
r.POST("/bindWxUser", bindWxUser)
//显示微信二维码
r.GET("/wxShowImg", wxShowImg)
return
}
@ -710,40 +705,3 @@ func bindWxUser(context *gin.Context) {
return
}
}
// @Summary 微信显示二维码
// @Description 微信显示二维码
// @Tags 登录验证类
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Success 200 {string} string
// @Router /oauth2/wxShowImg [get]
// http://10.10.14.187/oauth2/wxShowImg
func wxShowImg(context *gin.Context) {
url := `https://open.weixin.qq.com/connect/qrconnect?appid=wx3e0449144386938a&redirect_uri=http://fort.edusoa.com:7777/sso/static/jumpWx.html&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect`
//获取http代码
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
//下载文件到本地临时目录中
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)
}
}

@ -440,6 +440,29 @@ var doc = `{
]
}
},
"/oauth2/wxShowImg": {
"get": {
"description": "微信显示二维码",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"tags": [
"登录验证类"
],
"summary": "微信显示二维码",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/sso/addJoinApp": {
"post": {
"description": "增加一条接入系统的记录",

@ -424,6 +424,29 @@
]
}
},
"/oauth2/wxShowImg": {
"get": {
"description": "微信显示二维码",
"consumes": [
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"tags": [
"登录验证类"
],
"summary": "微信显示二维码",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/sso/addJoinApp": {
"post": {
"description": "增加一条接入系统的记录",

@ -317,6 +317,21 @@ paths:
- 登录验证类
x-emptylimit:
- code
/oauth2/wxShowImg:
get:
consumes:
- application/x-www-form-urlencoded
description: 微信显示二维码
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
summary: 微信显示二维码
tags:
- 登录验证类
/sso/addJoinApp:
post:
consumes:

Loading…
Cancel
Save