fusenapi/home-user-auth/internal/logic/userbasicinfologic.go
2023-06-07 18:30:58 +08:00

40 lines
976 B
Go

package logic
import (
"context"
"fusenapi/home-user-auth/internal/svc"
"fusenapi/home-user-auth/internal/types"
"fusenapi/model"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"github.com/zeromicro/go-zero/core/logx"
)
type UserBasicInfoLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewUserBasicInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserBasicInfoLogic {
return &UserBasicInfoLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *UserBasicInfoLogic) UserBasicInfo(req *types.Request) (resp *types.Response) {
loginInfo := auth.GetUserInfoFormCtx(l.ctx)
if loginInfo.UserId == 0 {
return resp.SetStatus(basic.CodeOK, "parse login info err ")
}
fsUserModel, err := model.NewFsUserModel(l.svcCtx.MysqlConn).FindOne(l.ctx, loginInfo.UserId)
if err != nil {
logx.Error(err)
return resp.Set(510, err.Error())
}
return resp.SetStatus(basic.CodeOK, fsUserModel)
}