From 1c3d7d77e8390988afafc4910c15188a8486bab1 Mon Sep 17 00:00:00 2001 From: huanghai <10402852@qq.com> Date: Thu, 30 Jul 2020 17:13:19 +0800 Subject: [PATCH] 'commit' --- .../ControllerOauth2/ControllerOauth2.go | 24 +++++++++++++++++++ dsSso/go.mod | 1 + dsSso/go.sum | 2 ++ 3 files changed, 27 insertions(+) diff --git a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go index 8225bcb9..e4a220b9 100644 --- a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go +++ b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go @@ -21,6 +21,7 @@ import ( "fmt" "github.com/dchest/captcha" "github.com/gin-gonic/gin" + "github.com/opesun/goquery" "github.com/tidwall/gjson" "io/ioutil" "net/http" @@ -48,6 +49,8 @@ func Routers(r *gin.RouterGroup) { r.GET("/resetRemainCount", resetRemainCount) //微信登录 r.POST("/wxLogin", wxLogin) + //微信二维码 + r.GET("/wxShowImg", wxShowImg) return } @@ -524,3 +527,24 @@ func wxLogin(context *gin.Context) { context.JSON(http.StatusOK, map[string]interface{}{"success": false, "openid": ""}) } } + +// @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": "获取微信图片发生异常!"}) + } else { + pTitle := p.Find("img").Attr("src") + pTitle = `https://open.weixin.qq.com/` + pTitle + context.JSON(http.StatusOK, map[string]interface{}{"success": true, "imgSrc": pTitle}) + } +} diff --git a/dsSso/go.mod b/dsSso/go.mod index 620eedd3..584427df 100644 --- a/dsSso/go.mod +++ b/dsSso/go.mod @@ -33,6 +33,7 @@ require ( github.com/mattn/go-isatty v0.0.12 // indirect github.com/mattn/go-sqlite3 v1.10.0 // indirect github.com/oklog/ulid v1.3.1 + github.com/opesun/goquery v0.0.0-20160908163916-0d77e43213cd // indirect github.com/pborman/uuid v1.2.0 // indirect github.com/pkg/errors v0.9.1 github.com/pkg/sftp v1.11.0 diff --git a/dsSso/go.sum b/dsSso/go.sum index ca7b56a4..c7a2c40e 100644 --- a/dsSso/go.sum +++ b/dsSso/go.sum @@ -241,6 +241,8 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= +github.com/opesun/goquery v0.0.0-20160908163916-0d77e43213cd h1:taV1toAfzAdRwNWpIB7JMdgX2xL+JT3Rq8GXzyPK1Is= +github.com/opesun/goquery v0.0.0-20160908163916-0d77e43213cd/go.mod h1:XIY7IuxoZH2deZdjIgzLqXlYkOHiwNC+hL1m3vS2A8g= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pierrec/lz4 v2.4.1+incompatible h1:mFe7ttWaflA46Mhqh+jUfjp2qTbPYxLB2/OyBppH9dg=