46 lines
980 B
Go
46 lines
980 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"godemo/gateway/internal/svc"
|
|
"godemo/gateway/internal/types"
|
|
"godemo/user/user"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetUserInfoLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
|
|
return &GetUserInfoLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetUserInfoLogic) GetUserInfo(req *types.GetUserInfoReq) (resp *types.GetUserInfoResp, err error) {
|
|
// todo: add your logic here and delete this line
|
|
rpcResp, err := l.svcCtx.UserRpc.GetUserInfo(l.ctx, &user.GetUserInfoRequest{
|
|
UserId: req.UserId,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// 构造 API 返回值
|
|
resp = &types.GetUserInfoResp{
|
|
UserId: rpcResp.UserId,
|
|
Username: rpcResp.Username,
|
|
Email: rpcResp.Email,
|
|
CreatedAt: rpcResp.CreatedAt,
|
|
Roles: rpcResp.Roles,
|
|
}
|
|
return
|
|
}
|