44 lines
965 B
Go
44 lines
965 B
Go
// Code scaffolded by goctl. Safe to edit.
|
|
// goctl 1.9.2
|
|
|
|
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"juwan-backend/app/user/api/internal/svc"
|
|
"juwan-backend/app/user/api/internal/types"
|
|
"juwan-backend/app/user/rpc/usercenter"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type UserInfoLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
// Get user infomaction by user id
|
|
func NewUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoLogic {
|
|
return &UserInfoLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *UserInfoLogic) UserInfo(req *types.UserInfoReq) (resp *types.UserInfoResp, err error) {
|
|
logx.Infof("Request user info, user id: %d", req.UserId)
|
|
res, err := l.svcCtx.Usercenter.GetUserInfo(l.ctx, &usercenter.GetUserInfoReq{
|
|
Id: req.UserId,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &types.UserInfoResp{
|
|
UserId: res.Id,
|
|
Nickname: res.Nickname,
|
|
}, nil
|
|
}
|