From 4c2f823178fb5d0dabd97ddfaa03b484d1e82fd2 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Mon, 24 Jul 2023 12:32:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/home-user-auth/internal/logic/userloginlogic.go | 5 +++++ server/home-user-auth/internal/types/types.go | 4 ++-- server_api/home-user-auth.api | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/home-user-auth/internal/logic/userloginlogic.go b/server/home-user-auth/internal/logic/userloginlogic.go index 628a5693..24d0b669 100644 --- a/server/home-user-auth/internal/logic/userloginlogic.go +++ b/server/home-user-auth/internal/logic/userloginlogic.go @@ -13,6 +13,7 @@ import ( "fusenapi/utils/basic" "github.com/zeromicro/go-zero/core/logx" + "github.com/zeromicro/go-zero/rest/httpx" "gorm.io/gorm" ) @@ -22,6 +23,7 @@ type UserLoginLogic struct { svcCtx *svc.ServiceContext token string + resp *basic.Response } func NewUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLoginLogic { @@ -36,6 +38,8 @@ func (l *UserLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request) { if l.token != "" { w.Header().Add("Authorization", fmt.Sprintf("Bearer %s", l.token)) } + + httpx.OkJsonCtx(r.Context(), w, l.resp) } func (l *UserLoginLogic) UserLogin(req *types.RequestUserLogin, userinfo *auth.UserInfo) (resp *basic.Response) { @@ -75,6 +79,7 @@ func (l *UserLoginLogic) UserLogin(req *types.RequestUserLogin, userinfo *auth.U } l.token = jwtToken + l.resp = resp.SetStatus(basic.CodeOK, data) // 返回认证成功的状态码以及数据对象 data 和 JWT Token。 return resp.SetStatus(basic.CodeOK, data) diff --git a/server/home-user-auth/internal/types/types.go b/server/home-user-auth/internal/types/types.go index 4a4c5fd3..cdb5446a 100644 --- a/server/home-user-auth/internal/types/types.go +++ b/server/home-user-auth/internal/types/types.go @@ -109,8 +109,8 @@ type RequestBasicInfoForm struct { } type RequestUserLogin struct { - Email string `form:"email"` - Password string `form:"password"` + Email string `json:"email"` + Password string `json:"password"` } type RequestAddAddress struct { diff --git a/server_api/home-user-auth.api b/server_api/home-user-auth.api index 2c273e75..fdc7594e 100644 --- a/server_api/home-user-auth.api +++ b/server_api/home-user-auth.api @@ -178,8 +178,8 @@ type RequestBasicInfoForm { // UserAddAddressHandler 用户登录请求结构 type RequestUserLogin { - Email string `form:"email"` - Password string `form:"password"` + Email string `json:"email"` + Password string `json:"password"` } // RequestAddAddress 增加地址结构