From 72a6412eedba18358fd83f09cc16552ca40d10b4 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Mon, 24 Jul 2023 10:27:06 +0800 Subject: [PATCH 1/4] fix --- .../home-user-auth/internal/logic/usergoogleloginlogic.go | 8 ++------ server/render/internal/config/config.go | 6 +++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/server/home-user-auth/internal/logic/usergoogleloginlogic.go b/server/home-user-auth/internal/logic/usergoogleloginlogic.go index 59825e69..c454d5af 100644 --- a/server/home-user-auth/internal/logic/usergoogleloginlogic.go +++ b/server/home-user-auth/internal/logic/usergoogleloginlogic.go @@ -60,10 +60,6 @@ func (l *UserGoogleLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request `, l.redirectUrl) fmt.Fprintln(w, html) - - // if l.redirectUrl != "" { - // http.Redirect(w, r, "http://localhost:9900/api/assistant/redirect?url="+url.QueryEscape(l.redirectUrl), http.StatusFound) - // } } func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, userinfo *auth.UserInfo) (resp *basic.Response) { @@ -108,8 +104,8 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us log.Println(r.Json()) googleId := r.Json().Get("id").Int() - l.redirectUrl = "http://localhost:9900/oauth?token=21321123" - return resp.Set(304, "21321321") + // l.redirectUrl = "http://localhost:9900/oauth?token=21321123" + // return resp.Set(304, "21321321") user, err := l.svcCtx.AllModels.FsUser.FindUserByGoogleId(context.TODO(), googleId) log.Println(user) if err != nil { diff --git a/server/render/internal/config/config.go b/server/render/internal/config/config.go index b24bb7d7..5f9c4816 100644 --- a/server/render/internal/config/config.go +++ b/server/render/internal/config/config.go @@ -1,6 +1,10 @@ package config -import "github.com/zeromicro/go-zero/rest" +import ( + "fusenapi/server/render/internal/types" + + "github.com/zeromicro/go-zero/rest" +) type Config struct { rest.RestConf From 1e2f6d8b7f6249f79d88cb49e0e4d2b4154cce1d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 24 Jul 2023 10:30:08 +0800 Subject: [PATCH 2/4] fix --- .../internal/logic/getproductlistlogic.go | 16 ++++++++-------- .../internal/logic/gettagproductlistlogic.go | 2 +- .../logic/homepagerecommendproductlistlogic.go | 2 +- server/product/internal/types/types.go | 6 +++--- server_api/product.api | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/server/product/internal/logic/getproductlistlogic.go b/server/product/internal/logic/getproductlistlogic.go index 6e27315d..f45b8418 100644 --- a/server/product/internal/logic/getproductlistlogic.go +++ b/server/product/internal/logic/getproductlistlogic.go @@ -143,14 +143,14 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri sizeNum = mapSizeNum } item := types.Items{ - Id: v.Id, - Sn: *v.Sn, - Title: *v.Title, - Intro: *v.Intro, - IsEnv: *v.IsProtection, - IsMicro: *v.IsMicrowave, - SizeNum: uint32(sizeNum), - MiniPrice: minPrice, + Id: v.Id, + Sn: *v.Sn, + Title: *v.Title, + Intro: *v.Intro, + IsEnv: *v.IsProtection, + IsMicro: *v.IsMicrowave, + SizeNum: uint32(sizeNum), + MinPrice: minPrice, } //千人千面处理 r := image.ThousandFaceImageFormatReq{ diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index f8d76155..7bd78504 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -330,7 +330,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL IsEnv: *productInfo.IsProtection, IsMicro: *productInfo.IsMicrowave, SizeNum: uint32(sizeNum), - MiniPrice: minPrice, + MinPrice: minPrice, HaveOptionalFitting: haveOptionalFitting, } //千人千面处理 diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index f4b88d65..60c4cdb0 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -153,7 +153,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty IsEnv: *productInfo.IsProtection, IsMicro: *productInfo.IsMicrowave, SizeNum: uint32(sizeNum), - MiniPrice: minPrice, + MinPrice: minPrice, HaveOptionalFitting: haveOptionalFitting, } //千人千面处理 diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index c45e4775..8109fec5 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -33,7 +33,7 @@ type Items struct { IsEnv int64 `json:"isEnv"` IsMicro int64 `json:"isMicro"` SizeNum uint32 `json:"sizeNum"` - MiniPrice int64 `json:"miniPrice"` + MinPrice int64 `json:"minPrice"` CoverDefault string `json:"coverDefault"` } @@ -279,7 +279,7 @@ type TagProduct struct { IsEnv int64 `json:"is_env"` IsMicro int64 `json:"is_micro"` SizeNum uint32 `json:"size_num"` - MiniPrice int64 `json:"mini_price"` + MinPrice int64 `json:"min_price"` CoverDefault string `json:"cover_default"` HaveOptionalFitting bool `json:"have_optional_fitting"` } @@ -401,7 +401,7 @@ type HomePageRecommendProductListRsp struct { IsEnv int64 `json:"is_env"` IsMicro int64 `json:"is_micro"` SizeNum uint32 `json:"size_num"` - MiniPrice int64 `json:"mini_price"` + MinPrice int64 `json:"min_price"` CoverDefault string `json:"cover_default"` HaveOptionalFitting bool `json:"have_optional_fitting"` } diff --git a/server_api/product.api b/server_api/product.api index fdfdbc0c..a7160506 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -103,7 +103,7 @@ type Items { IsEnv int64 `json:"isEnv"` IsMicro int64 `json:"isMicro"` SizeNum uint32 `json:"sizeNum"` - MiniPrice int64 `json:"miniPrice"` + MinPrice int64 `json:"minPrice"` CoverDefault string `json:"coverDefault"` } //获取支付成功后推荐产品 @@ -328,7 +328,7 @@ type TagProduct { IsEnv int64 `json:"is_env"` IsMicro int64 `json:"is_micro"` SizeNum uint32 `json:"size_num"` - MiniPrice int64 `json:"mini_price"` + MinPrice int64 `json:"min_price"` CoverDefault string `json:"cover_default"` HaveOptionalFitting bool `json:"have_optional_fitting"` } @@ -443,7 +443,7 @@ type HomePageRecommendProductListRsp { IsEnv int64 `json:"is_env"` IsMicro int64 `json:"is_micro"` SizeNum uint32 `json:"size_num"` - MiniPrice int64 `json:"mini_price"` + MinPrice int64 `json:"min_price"` CoverDefault string `json:"cover_default"` HaveOptionalFitting bool `json:"have_optional_fitting"` } \ No newline at end of file From b0c9c8d310b9463a01b799fe9ea77ddbd5496464 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 24 Jul 2023 10:37:11 +0800 Subject: [PATCH 3/4] fix --- server/product/internal/logic/gettagproductlistlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 7bd78504..8a185eea 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -223,7 +223,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq) TagProductList: nil, TypeName: *tagInfo.Title, TypeId: tagInfo.Id, - Level: *tagInfo.Level, + Level: int64(lenLevel), LevelPrefix: *tagInfo.LevelPrefix, Icon: *tagInfo.Icon, Sort: *tagInfo.Sort, From 900d5bf24bb0c7464ccf4330f8b2562469ab5a85 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Mon, 24 Jul 2023 12:18:27 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/home-user-auth/etc/home-user-auth.yaml | 1 + .../home-user-auth/internal/config/config.go | 2 + .../home-user-auth/internal/handler/routes.go | 5 ++ .../handler/useremailregisterhandler.go | 35 ++++++++++++++ .../internal/handler/userloginhandler.go | 31 +++++------- .../internal/logic/useremailregisterlogic.go | 42 ++++++++++++++++ .../internal/logic/usergoogleloginlogic.go | 22 +++++++-- .../internal/logic/userloginlogic.go | 26 +++++++--- .../internal/logic/useroauth2loginlogic.go | 35 -------------- server/home-user-auth/internal/types/types.go | 11 +++-- server_api/home-user-auth.api | 48 ++++++++++--------- 11 files changed, 167 insertions(+), 91 deletions(-) create mode 100644 server/home-user-auth/internal/handler/useremailregisterhandler.go create mode 100644 server/home-user-auth/internal/logic/useremailregisterlogic.go delete mode 100644 server/home-user-auth/internal/logic/useroauth2loginlogic.go diff --git a/server/home-user-auth/etc/home-user-auth.yaml b/server/home-user-auth/etc/home-user-auth.yaml index 7b8747f2..7ef5a2c9 100644 --- a/server/home-user-auth/etc/home-user-auth.yaml +++ b/server/home-user-auth/etc/home-user-auth.yaml @@ -1,6 +1,7 @@ Name: home-user-auth Host: 0.0.0.0 Port: 9904 +MainAddress: "http://localhost:9900" SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: diff --git a/server/home-user-auth/internal/config/config.go b/server/home-user-auth/internal/config/config.go index 63e5a39a..19c515b1 100644 --- a/server/home-user-auth/internal/config/config.go +++ b/server/home-user-auth/internal/config/config.go @@ -11,6 +11,8 @@ type Config struct { SourceMysql string Auth types.Auth + MainAddress string + OAuth struct { Google struct { Appid string diff --git a/server/home-user-auth/internal/handler/routes.go b/server/home-user-auth/internal/handler/routes.go index 88082836..75ac9d8f 100644 --- a/server/home-user-auth/internal/handler/routes.go +++ b/server/home-user-auth/internal/handler/routes.go @@ -72,6 +72,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/user/oauth2/login/google", Handler: UserGoogleLoginHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/api/user/oauth2/login/register", + Handler: UserEmailRegisterHandler(serverCtx), + }, { Method: http.MethodGet, Path: "/api/user/order-list", diff --git a/server/home-user-auth/internal/handler/useremailregisterhandler.go b/server/home-user-auth/internal/handler/useremailregisterhandler.go new file mode 100644 index 00000000..a245432e --- /dev/null +++ b/server/home-user-auth/internal/handler/useremailregisterhandler.go @@ -0,0 +1,35 @@ +package handler + +import ( + "net/http" + "reflect" + + "fusenapi/utils/basic" + + "fusenapi/server/home-user-auth/internal/logic" + "fusenapi/server/home-user-auth/internal/svc" + "fusenapi/server/home-user-auth/internal/types" +) + +func UserEmailRegisterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var req types.RequestEmailRegister + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } + + // 创建一个业务逻辑层实例 + l := logic.NewUserEmailRegisterLogic(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.UserEmailRegister(&req, userinfo) + + if !basic.AfterLogic(w, r, rl) { + basic.NormalAfterLogic(w, r, resp) + } + } +} diff --git a/server/home-user-auth/internal/handler/userloginhandler.go b/server/home-user-auth/internal/handler/userloginhandler.go index 020e407e..e880a060 100644 --- a/server/home-user-auth/internal/handler/userloginhandler.go +++ b/server/home-user-auth/internal/handler/userloginhandler.go @@ -1,40 +1,35 @@ package handler import ( - "errors" - "fmt" "net/http" + "reflect" - "github.com/zeromicro/go-zero/core/logx" - "github.com/zeromicro/go-zero/rest/httpx" + "fusenapi/utils/basic" "fusenapi/server/home-user-auth/internal/logic" "fusenapi/server/home-user-auth/internal/svc" "fusenapi/server/home-user-auth/internal/types" - "fusenapi/utils/basic" ) -// UserLoginHandler 特殊的登录获取jwt token处理 func UserLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var req types.RequestUserLogin + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } // 创建一个业务逻辑层实例 l := logic.NewUserLoginLogic(r.Context(), svcCtx) - resp, token := l.UserLogin(&req) - if resp.Code == basic.CodeOK.Code { - w.Header().Add("Authorization", fmt.Sprintf("Bearer %s", token)) - } - // 如果响应不为nil,则使用httpx.OkJsonCtx方法返回JSON响应; - // 否则,发送500内部服务器错误的JSON响应并记录错误消息logx.Error。 - if resp != nil { - httpx.OkJsonCtx(r.Context(), w, resp) - } else { - err := errors.New("server logic is error, resp must not be nil") - httpx.ErrorCtx(r.Context(), w, err) - logx.Error(err) + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.UserLogin(&req, userinfo) + + if !basic.AfterLogic(w, r, rl) { + basic.NormalAfterLogic(w, r, resp) } } } diff --git a/server/home-user-auth/internal/logic/useremailregisterlogic.go b/server/home-user-auth/internal/logic/useremailregisterlogic.go new file mode 100644 index 00000000..34c29487 --- /dev/null +++ b/server/home-user-auth/internal/logic/useremailregisterlogic.go @@ -0,0 +1,42 @@ +package logic + +import ( + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "context" + + "fusenapi/server/home-user-auth/internal/svc" + "fusenapi/server/home-user-auth/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UserEmailRegisterLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUserEmailRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserEmailRegisterLogic { + return &UserEmailRegisterLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// 处理进入前逻辑w,r +// func (l *UserEmailRegisterLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { +// } + +// 处理逻辑后 w,r 如:重定向 +// func (l *UserEmailRegisterLogic) AfterLogic(w http.ResponseWriter, r *http.Request) { +// } + +func (l *UserEmailRegisterLogic) UserEmailRegister(req *types.RequestEmailRegister, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + + return resp.SetStatus(basic.CodeOK) +} diff --git a/server/home-user-auth/internal/logic/usergoogleloginlogic.go b/server/home-user-auth/internal/logic/usergoogleloginlogic.go index c454d5af..50b7683b 100644 --- a/server/home-user-auth/internal/logic/usergoogleloginlogic.go +++ b/server/home-user-auth/internal/logic/usergoogleloginlogic.go @@ -27,7 +27,10 @@ type UserGoogleLoginLogic struct { ctx context.Context svcCtx *svc.ServiceContext - redirectUrl string + token string // 登录 token + + isRegistered bool // 是否注册 + registerToken string // 注册邮箱的token } func NewUserGoogleLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserGoogleLoginLogic { @@ -44,6 +47,13 @@ func NewUserGoogleLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *U func (l *UserGoogleLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request) { + rurl := fmt.Sprintf( + l.svcCtx.Config.MainAddress+"/oauth?token=%s&is_registered=%t®ister_token=%s", + l.token, + l.isRegistered, + l.registerToken, + ) + html := fmt.Sprintf(` @@ -58,7 +68,7 @@ func (l *UserGoogleLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request - `, l.redirectUrl) + `, rurl) fmt.Fprintln(w, html) } @@ -104,17 +114,21 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us log.Println(r.Json()) googleId := r.Json().Get("id").Int() - // l.redirectUrl = "http://localhost:9900/oauth?token=21321123" + + // l.redirectUrl = "http://localhost:9900/oauth?token=21321123&is_registered" // return resp.Set(304, "21321321") user, err := l.svcCtx.AllModels.FsUser.FindUserByGoogleId(context.TODO(), googleId) log.Println(user) if err != nil { if err != gorm.ErrRecordNotFound { logx.Error(err) - return resp.SetStatus(basic.CodeDbSqlErr) } + if req.Email == "" { + return resp.SetStatus(basic.CodeOK) + } + // 如果密码匹配,则生成 JWT Token。 nowSec := time.Now().Unix() jwtToken, err := auth.GenerateJwtToken(&l.svcCtx.Config.Auth.AccessSecret, l.svcCtx.Config.Auth.AccessExpire, nowSec, 0, 0) diff --git a/server/home-user-auth/internal/logic/userloginlogic.go b/server/home-user-auth/internal/logic/userloginlogic.go index 65ec96ce..628a5693 100644 --- a/server/home-user-auth/internal/logic/userloginlogic.go +++ b/server/home-user-auth/internal/logic/userloginlogic.go @@ -3,6 +3,8 @@ package logic import ( "context" "errors" + "fmt" + "net/http" "time" "fusenapi/server/home-user-auth/internal/svc" @@ -18,6 +20,8 @@ type UserLoginLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext + + token string } func NewUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLoginLogic { @@ -28,35 +32,41 @@ func NewUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserLog } } -func (l *UserLoginLogic) UserLogin(req *types.RequestUserLogin) (resp *basic.Response, jwtToken string) { +func (l *UserLoginLogic) AfterLogic(w http.ResponseWriter, r *http.Request) { + if l.token != "" { + w.Header().Add("Authorization", fmt.Sprintf("Bearer %s", l.token)) + } +} + +func (l *UserLoginLogic) UserLogin(req *types.RequestUserLogin, userinfo *auth.UserInfo) (resp *basic.Response) { // 创建一个 FsUserModel 对象 m 并实例化之,该对象用于操作 MySQL 数据库中的用户数据表。 m := l.svcCtx.AllModels.FsUser // 在用户数据表中根据登录名(email)查找用户记录,并返回 UserModel 类型的结构体对象 userModel。 user, err := m.FindUserByEmail(l.ctx, req.Email) if errors.Is(err, gorm.ErrRecordNotFound) { - return resp.SetStatus(basic.CodeEmailNotFoundErr), "" + return resp.SetStatus(basic.CodeEmailNotFoundErr) } // 如果在用户数据表中找到了登录名匹配的用户记录,则判断密码是否匹配。 if *user.PasswordHash != req.Password { logx.Info("密码错误") - return resp.SetStatus(basic.CodePasswordErr), jwtToken + return resp.SetStatus(basic.CodePasswordErr) } // 如果密码匹配,则生成 JWT Token。 nowSec := time.Now().Unix() - jwtToken, err = auth.GenerateJwtToken(&l.svcCtx.Config.Auth.AccessSecret, l.svcCtx.Config.Auth.AccessExpire, nowSec, user.Id, 0) + jwtToken, err := auth.GenerateJwtToken(&l.svcCtx.Config.Auth.AccessSecret, l.svcCtx.Config.Auth.AccessExpire, nowSec, user.Id, 0) // 如果生成 JWT Token 失败,则抛出错误并返回未认证的状态码。 if err != nil { logx.Error(err) - return resp.SetStatus(basic.CodeUnAuth), jwtToken + return resp.SetStatus(basic.CodeUnAuth) } // 如果更新 VerificationToken 字段失败,则返回未认证的状态码。 if err != nil { - return resp.SetStatus(basic.CodeUnAuth), jwtToken + return resp.SetStatus(basic.CodeUnAuth) } // 构造 DataUserLogin 类型的数据对象 data 并设置其属性值为生成的 JWT Token。 @@ -64,6 +74,8 @@ func (l *UserLoginLogic) UserLogin(req *types.RequestUserLogin) (resp *basic.Res Token: jwtToken, } + l.token = jwtToken + // 返回认证成功的状态码以及数据对象 data 和 JWT Token。 - return resp.SetStatus(basic.CodeOK, data), jwtToken + return resp.SetStatus(basic.CodeOK, data) } diff --git a/server/home-user-auth/internal/logic/useroauth2loginlogic.go b/server/home-user-auth/internal/logic/useroauth2loginlogic.go deleted file mode 100644 index ac4e189f..00000000 --- a/server/home-user-auth/internal/logic/useroauth2loginlogic.go +++ /dev/null @@ -1,35 +0,0 @@ -package logic - -import ( - "fusenapi/utils/auth" - "fusenapi/utils/basic" - - "context" - - "fusenapi/server/home-user-auth/internal/svc" - "fusenapi/server/home-user-auth/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type UserOAuth2LoginLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewUserOAuth2LoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserOAuth2LoginLogic { - - return &UserOAuth2LoginLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *UserOAuth2LoginLogic) UserOAuth2Login(req *types.RequestOAuth, userinfo *auth.UserInfo) (resp *basic.Response) { - // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) - // userinfo 传入值时, 一定不为null - - return resp.SetStatus(basic.CodeOK) -} diff --git a/server/home-user-auth/internal/types/types.go b/server/home-user-auth/internal/types/types.go index 9679e889..4a4c5fd3 100644 --- a/server/home-user-auth/internal/types/types.go +++ b/server/home-user-auth/internal/types/types.go @@ -75,11 +75,12 @@ type RequestGoogleLogin struct { Scope string `form:"scope"` AuthUser string `form:"authuser"` Prompt string `form:"prompt"` + Email string `form:"email,optional"` } -type RequestOAuth struct { - Platform string `json:"platform"` - Code string `json:"code"` +type RequestEmailRegister struct { + Email string `json:"email"` + RegisterToken string `json:"register_token"` } type RequestContactService struct { @@ -108,8 +109,8 @@ type RequestBasicInfoForm struct { } type RequestUserLogin struct { - Email string `json:"email"` - Password string `json:"password"` + Email string `form:"email"` + Password string `form:"password"` } type RequestAddAddress struct { diff --git a/server_api/home-user-auth.api b/server_api/home-user-auth.api index 1ad9b6a4..2c273e75 100644 --- a/server_api/home-user-auth.api +++ b/server_api/home-user-auth.api @@ -10,57 +10,60 @@ info ( import "basic.api" service home-user-auth { - + // @handler UserRegisterHandler // post /api/user/register(RequestUserRegister) returns (response); - + @handler UserLoginHandler post /api/user/login(RequestUserLogin) returns (response); - + @handler AcceptCookieHandler post /api/user/accept-cookie(request) returns (response); - + @handler UserFontsHandler get /api/user/fonts(request) returns (response); - + @handler UserGetTypeHandler get /api/user/get-type(request) returns (response); - + @handler UserSaveBasicInfoHandler post /api/user/basic-info(RequestBasicInfoForm) returns (response); - + @handler UserStatusConfigHandler get /api/user/status-config(request) returns (response); - + @handler UserBasicInfoHandler get /api/user/basic-info(request) returns (response); - + @handler UserAddressListHandler get /api/user/address-list(request) returns (response); - + @handler UserAddAddressHandler post /api/user/add-address(RequestAddAddress) returns (response); - + @handler UserContactServiceHandler post /api/user/contact-service (RequestContactService) returns (response); - + // @handler UserOderListHandler // get /api/user/order-list(RequestOrderId) returns (response); - + @handler UserOderDeleteHandler post /api/user/order-delete(RequestOrderId) returns (response); - + @handler UserGoogleLoginHandler get /api/user/oauth2/login/google(RequestGoogleLogin) returns (response); - + + @handler UserEmailRegisterHandler + get /api/user/oauth2/login/register(RequestEmailRegister) returns (response); + //订单列表 @handler UserOrderListHandler get /api/user/order-list (UserOrderListReq) returns (response); - + //取消订单 @handler UserOrderCancelHandler get /api/user/order-cancel (UserOrderCancelReq) returns (response); - + } //取消订单 @@ -138,11 +141,12 @@ type RequestGoogleLogin { Scope string `form:"scope"` AuthUser string `form:"authuser"` Prompt string `form:"prompt"` + Email string `form:"email,optional"` } -type RequestOAuth { - Platform string `json:"platform"` - Code string `json:"code"` +type RequestEmailRegister { + Email string `json:"email"` + RegisterToken string `json:"register_token"` } type RequestContactService { @@ -174,8 +178,8 @@ type RequestBasicInfoForm { // UserAddAddressHandler 用户登录请求结构 type RequestUserLogin { - Email string `json:"email"` - Password string `json:"password"` + Email string `form:"email"` + Password string `form:"password"` } // RequestAddAddress 增加地址结构