41 lines
801 B
Go
41 lines
801 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 RegisterLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewRegisterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterLogic {
|
|
return &RegisterLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *RegisterLogic) Register(req *types.RegisterReq) (resp *types.RegisterResp, err error) {
|
|
rpcResp, err := l.svcCtx.UserRpc.Register(l.ctx, &user.RegisterRequest{
|
|
Email: req.Email,
|
|
Password: req.Password,
|
|
Username: req.Username,
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resp = &types.RegisterResp{
|
|
UserId: rpcResp.UserId,
|
|
}
|
|
return
|
|
}
|