This commit is contained in:
laodaming
2023-06-07 11:35:04 +08:00
parent ef50dbb6fe
commit 3d492ff720
14 changed files with 117 additions and 117 deletions

View File

@@ -10,7 +10,6 @@ import (
"fusenapi/home-user-auth/internal/logic"
"fusenapi/home-user-auth/internal/svc"
"fusenapi/home-user-auth/internal/types"
"fusenapi/utils/auth"
)
func UserBasicInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
@@ -26,8 +25,7 @@ func UserBasicInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := logic.NewUserBasicInfoLogic(r.Context(), svcCtx)
userinfo := auth.CheckAuth(r)
resp := l.UserBasicInfo(&req, &userinfo)
resp := l.UserBasicInfo(&req)
if resp != nil {
httpx.OkJsonCtx(r.Context(), w, resp)
} else {

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,6 +2,7 @@ package logic
import (
"context"
"fusenapi/utils/auth"
"fusenapi/home-user-auth/internal/svc"
"fusenapi/home-user-auth/internal/types"
@@ -28,15 +29,12 @@ func NewUserSaveBasicInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext)
func (l *UserSaveBasicInfoLogic) UserSaveBasicInfo(req *types.RequestBasicInfoForm) (resp *types.Response) {
// 必须返回response, 前端需要的是内部约定的Code码, 处理相关的逻辑. 例子(eg): resp.Set(501, "error")
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)
fsUserModel, err := model.NewFsUserModel(l.svcCtx.MysqlConn).FindOne(l.ctx, userid)
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, loginInfo.UserId)
if err != nil {
logx.Error(err)
}