Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into develop

This commit is contained in:
eson
2023-06-07 11:50:49 +08:00
16 changed files with 172 additions and 282 deletions

View File

@@ -2,8 +2,6 @@ package logic
import (
"context"
"log"
"fusenapi/home-user-auth/internal/svc"
"fusenapi/home-user-auth/internal/types"
"fusenapi/model"
@@ -27,22 +25,15 @@ func NewUserBasicInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Use
}
}
func (l *UserBasicInfoLogic) UserBasicInfo(req *types.Request, userinfo *auth.UserInfo) (resp *types.Response) {
func (l *UserBasicInfoLogic) UserBasicInfo(req *types.Request) (resp *types.Response) {
// 必须返回response, 前端需要的是内部约定的Code码, 处理相关的逻辑. 例子(eg): resp.Set(501, "error")
resp = &types.Response{}
// u := l.ctx.Value("userid").(int64)
u := l.ctx.Value("userid")
log.Println(u)
if userinfo.UserId == 0 {
resp = &types.Response{
Code: 510,
Message: "user is not exists",
}
loginInfo := auth.GetUserInfoFormCtx(l.ctx)
if loginInfo.UserId == 0 {
resp.SetStatus(basic.CodeOK, "parse login info err ")
return resp
}
fsUserModel, err := model.NewFsUserModel(l.svcCtx.MysqlConn).FindOne(l.ctx, userinfo.UserId)
fsUserModel, err := model.NewFsUserModel(l.svcCtx.MysqlConn).FindOne(l.ctx, loginInfo.UserId)
if err != nil {
logx.Error(err)
resp.Set(510, err.Error())

View File

@@ -2,7 +2,7 @@ package logic
import (
"context"
"strconv"
"fusenapi/utils/auth"
"fusenapi/home-user-auth/internal/svc"
"fusenapi/home-user-auth/internal/types"
@@ -30,16 +30,15 @@ func (l *UserSaveBasicInfoLogic) UserSaveBasicInfo(req *types.RequestBasicInfoFo
// 必须返回response, 前端需要的是内部约定的Code码, 处理相关的逻辑. 例子(eg): resp.Set(501, "error")
resp = &types.Response{}
userid, err := strconv.ParseInt(l.ctx.Value("userid").(string), 10, 64)
if err != nil {
resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
loginInfo := auth.GetUserInfoFormCtx(l.ctx)
if loginInfo.UserId == 0 {
resp.SetStatus(basic.CodeOK, "parse login info err ")
return resp
}
fsUserModel, err := model.NewFsUserModel(l.svcCtx.MysqlConn).FindOne(l.ctx, userid)
fsUserModel, err := model.NewFsUserModel(l.svcCtx.MysqlConn).FindOne(l.ctx, loginInfo.UserId)
if err != nil {
if err == model.ErrNotFound {
resp.SetStatusWithMessage(basic.CodeOK, "user is not exists")
return resp
}
logx.Error(err)