genlong 7 mesi fa
parent
commit
e924aae770
3 ha cambiato i file con 16 aggiunte e 11 eliminazioni
  1. 13 8
      controllers/user/wechat.go
  2. 0 2
      middleware/auth_middleware.go
  3. 3 1
      service/auth/auth_service.go

+ 13 - 8
controllers/user/wechat.go

@@ -4,7 +4,6 @@ import (
 	logger "eta/eta_mini_ht_api/common/component/log"
 	"eta/eta_mini_ht_api/common/exception"
 	"eta/eta_mini_ht_api/controllers"
-	"eta/eta_mini_ht_api/service/auth"
 )
 
 // RefreshToken 绑定微信公众号
@@ -20,13 +19,19 @@ func (a *AuthController) BindGzh(code string) {
 			return result, exception.New(exception.WeChatCodeEmpty)
 		}
 		//刷新token
-		err = auth.BindWxGzh(code)
-		if err != nil {
-			logger.Error("绑定公众号失败:%v", err)
-			a.FailedResult("绑定公众号失败", result)
-			return
-		}
-		a.SuccessResult("绑定成功", nil, result)
+		//isBind, err := auth.BindWxGzh(code)
+		//if err != nil {
+		//	logger.Error("绑定公众号失败:%v", err)
+		//	a.FailedResult("绑定公众号失败", result)
+		//	return
+		//}
+		//a.SuccessResult("绑定成功", IsBindGzhRes{
+		//	IsBind: isBind,
+		//}, result)
 		return
 	})
 }
+
+type IsBindGzhRes struct {
+	IsBind bool `json:"isBind"`
+}

+ 0 - 2
middleware/auth_middleware.go

@@ -46,8 +46,6 @@ func AuthMiddleware() web.FilterFunc {
 	return func(ctx *context.Context) {
 		path := ctx.Input.URL()
 		logger.Info("请求路径:%v", path)
-		f := allowed(path)
-		fmt.Println(f)
 		if !allowed(path) {
 			rep := unAuthorized()
 			auth := ctx.Input.Header(authorization)

+ 3 - 1
service/auth/auth_service.go

@@ -297,7 +297,7 @@ func BindXcxOpenId(userId int, openId string) (err error) {
 }
 
 // 绑定微信公众号
-func BindWxGzh(code string) (err error) {
+func BindWxGzh(code string) (isBind bool, err error) {
 	//注册用户
 	wxUser, err := GetWxUserInfo(code)
 	if err != nil {
@@ -354,6 +354,8 @@ func BindWxGzh(code string) (err error) {
 		} else { //修改微信小程序openid
 			err = userService.BindUserXcxOpenId(wxUser.Id, openId)
 		}
+	} else {
+		isBind = true
 	}
 	return
 }