更新
This commit is contained in:
parent
ef50dbb6fe
commit
f6ed43229d
@ -13,7 +13,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
server.AddRoutes(
|
server.AddRoutes(
|
||||||
[]rest.Route{
|
[]rest.Route{
|
||||||
{
|
{
|
||||||
Method: http.MethodPost,
|
Method: http.MethodGet,
|
||||||
Path: "/user/login",
|
Path: "/user/login",
|
||||||
Handler: UserLoginHandler(serverCtx),
|
Handler: UserLoginHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
@ -2,6 +2,7 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"fusenapi/home-user-auth/internal/svc"
|
"fusenapi/home-user-auth/internal/svc"
|
||||||
"fusenapi/home-user-auth/internal/types"
|
"fusenapi/home-user-auth/internal/types"
|
||||||
@ -28,17 +29,21 @@ func NewUserSaveBasicInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||||||
func (l *UserSaveBasicInfoLogic) UserSaveBasicInfo(req *types.RequestBasicInfoForm) (resp *types.Response) {
|
func (l *UserSaveBasicInfoLogic) UserSaveBasicInfo(req *types.RequestBasicInfoForm) (resp *types.Response) {
|
||||||
// 必须返回response, 前端需要的是内部约定的Code码, 处理相关的逻辑. 例子(eg): resp.Set(501, "error")
|
// 必须返回response, 前端需要的是内部约定的Code码, 处理相关的逻辑. 例子(eg): resp.Set(501, "error")
|
||||||
resp = &types.Response{}
|
resp = &types.Response{}
|
||||||
// logx.Info(req)
|
|
||||||
// if userinfo.UserId == 0 {
|
|
||||||
// resp.SetStatusWithMessage(basic.DefaultError, "user is not exists")
|
|
||||||
// return resp
|
|
||||||
// }
|
|
||||||
|
|
||||||
userid := l.ctx.Value("userid").(int64)
|
userid, err := strconv.ParseInt(l.ctx.Value("userid").(string), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
fsUserModel, err := model.NewFsUserModel(l.svcCtx.MysqlConn).FindOne(l.ctx, userid)
|
fsUserModel, err := model.NewFsUserModel(l.svcCtx.MysqlConn).FindOne(l.ctx, userid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == model.ErrNotFound {
|
||||||
|
resp.SetStatusWithMessage(basic.CodeOK, "user is not exists")
|
||||||
|
return resp
|
||||||
|
}
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.SetStatus(basic.CodeOK, fsUserModel)
|
resp.SetStatus(basic.CodeOK, fsUserModel)
|
||||||
|
@ -16,7 +16,7 @@ type request {
|
|||||||
|
|
||||||
service home-user-auth {
|
service home-user-auth {
|
||||||
@handler UserLoginHandler
|
@handler UserLoginHandler
|
||||||
post /user/login(RequestUserLogin) returns (responseJwt);
|
post /user/login(RequestUserLogin) returns (response);
|
||||||
|
|
||||||
@handler UserFontsHandler
|
@handler UserFontsHandler
|
||||||
get /user/fonts(request) returns (response);
|
get /user/fonts(request) returns (response);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user