fusenapi/server/home-user-auth/internal/logic/userbasicinfologic.go

40 lines
1015 B
Go
Raw Normal View History

2023-06-01 10:35:09 +00:00
package logic
import (
"context"
2023-06-05 09:56:55 +00:00
"fusenapi/model"
2023-06-08 02:51:56 +00:00
"fusenapi/server/home-user-auth/internal/svc"
"fusenapi/server/home-user-auth/internal/types"
2023-06-05 09:56:55 +00:00
"fusenapi/utils/auth"
"fusenapi/utils/basic"
2023-06-01 10:35:09 +00:00
"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,
}
}
2023-06-12 07:17:42 +00:00
func (l *UserBasicInfoLogic) UserBasicInfo(req *types.Request, userinfo *auth.UserInfo) (resp *types.Response) {
2023-06-07 03:35:04 +00:00
loginInfo := auth.GetUserInfoFormCtx(l.ctx)
if loginInfo.UserId == 0 {
2023-06-07 03:57:04 +00:00
return resp.SetStatus(basic.CodeOK, "parse login info err ")
2023-06-05 09:56:55 +00:00
}
2023-06-07 03:35:04 +00:00
fsUserModel, err := model.NewFsUserModel(l.svcCtx.MysqlConn).FindOne(l.ctx, loginInfo.UserId)
2023-06-05 09:56:55 +00:00
if err != nil {
logx.Error(err)
2023-06-07 03:57:04 +00:00
return resp.Set(510, err.Error())
2023-06-05 09:56:55 +00:00
}
2023-06-07 03:57:04 +00:00
return resp.SetStatus(basic.CodeOK, fsUserModel)
2023-06-01 10:35:09 +00:00
}