genlong 8 tháng trước cách đây
mục cha
commit
b2a801c28a

+ 16 - 2
controllers/user/user_controller.go

@@ -1,6 +1,7 @@
 package user
 
 import (
+	"encoding/json"
 	"eta/eta_mini_ht_api/common/component/cache"
 	logger "eta/eta_mini_ht_api/common/component/log"
 	"eta/eta_mini_ht_api/common/exception"
@@ -302,9 +303,18 @@ func covertToUserProfile(user user.User) UserProfileReq {
 // @Summary 绑定微信公众号
 // @Success 200 {object} controllers.BaseResponse
 // @Description 更新token
-// @router /bind_gzh [get]
-func (a *UserController) BindGzh(code string) {
+// @router /bind_gzh [post]
+func (a *UserController) BindGzh() {
 	controllers.Wrap(&a.BaseController, func() (result *controllers.WrapData, err error) {
+		bindReq := new(BindGzhReq)
+		body := a.Ctx.Input.RequestBody
+		err = json.Unmarshal(body, &bindReq)
+		if err != nil {
+			logger.Error("解析参数失败,Err:" + err.Error())
+			return result, exception.New(exception.WeChatCodeEmpty)
+		}
+
+		code := bindReq.Code
 		result = a.InitWrapData("绑定公众号失败")
 		if code == "" {
 			logger.Error("code不能为空")
@@ -330,3 +340,7 @@ func (a *UserController) BindGzh(code string) {
 type IsBindGzhRes struct {
 	IsBind bool `json:"isBind"`
 }
+
+type BindGzhReq struct {
+	Code string
+}

+ 1 - 1
routers/commentsRouter.go

@@ -259,7 +259,7 @@ func init() {
         beego.ControllerComments{
             Method: "BindGzh",
             Router: `/bind_gzh`,
-            AllowHTTPMethods: []string{"get"},
+            AllowHTTPMethods: []string{"post"},
             MethodParams: param.Make(
 				param.New("code"),
 			),

+ 3 - 3
service/auth/auth_service.go

@@ -313,9 +313,9 @@ func BindWxGzh(code string) (isBind bool, err error) {
 	}
 
 	openId := wxUser.OpenId
-	wxUserDetail, er := GetWxUserDetail(openId)
-	if er != nil {
-		logger.Error("获取微信公众号用户详细信息失败" + wxUserDetail.ErrMsg)
+	wxUserDetail, err := GetWxUserDetail(openId)
+	if err != nil {
+		logger.Error("获取微信公众号用户详细信息失败" + err.Error())
 		err = exception.New(exception.TemplateUserNotFound)
 		return
 	}