initial commit
This commit is contained in:
45
gateway/internal/logic/getuserinfologic.go
Normal file
45
gateway/internal/logic/getuserinfologic.go
Normal file
@ -0,0 +1,45 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user