42 lines
887 B
Go
Raw Normal View History

package user
import (
"context"
"muyu-apiserver/gateway/internal/svc"
"muyu-apiserver/gateway/internal/types"
"muyu-apiserver/rpc/system/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateUserLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreateUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateUserLogic {
return &CreateUserLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CreateUserLogic) CreateUser(req *types.CreateUserReq) (resp *types.IdResp, err error) {
rpcResp, err := l.svcCtx.SystemRpc.CreateUser(l.ctx, &pb.CreateUserReq{
Username: req.Username,
Password: req.Password,
RealName: req.RealName,
Phone: req.Phone,
Email: req.Email,
RoleId: req.RoleId,
})
if err != nil {
return nil, err
}
return &types.IdResp{Id: rpcResp.Id}, nil
}