38 lines
851 B
Go
38 lines
851 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"juwan-backend/app/users/rpc/internal/svc"
|
|
"juwan-backend/app/users/rpc/pb"
|
|
"juwan-backend/common/converter"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetUsersByIdLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetUsersByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUsersByIdLogic {
|
|
return &GetUsersByIdLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetUsersByIdLogic) GetUsersById(in *pb.GetUsersByIdReq) (*pb.GetUsersByIdResp, error) {
|
|
// todo: add your logic here and delete this line
|
|
user, err := l.svcCtx.UsersModelRO.FindOne(l.ctx, in.Id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
pbUser := &pb.Users{}
|
|
converter.StructToStruct(&user, &pbUser)
|
|
|
|
return &pb.GetUsersByIdResp{Users: pbUser}, nil
|
|
}
|