You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/examples/transaction/ent/internal/service/transaction.go

32 lines
711 B

package service
import (
"context"
"strconv"
pb "github.com/go-kratos/kratos/examples/transaction/api/transaction/v1"
"github.com/go-kratos/kratos/examples/transaction/ent/internal/biz"
"github.com/go-kratos/kratos/v2/log"
)
func NewTransactionService(user *biz.UserUsecase, logger log.Logger) *TransactionService {
return &TransactionService{
user: user,
log: log.NewHelper(logger),
}
}
func (b *TransactionService) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*pb.CreateUserReply, error) {
id, err := b.user.CreateUser(ctx, &biz.User{
Name: in.Name,
Email: in.Email,
})
if err != nil {
return nil, err
}
return &pb.CreateUserReply{
Id: strconv.Itoa(id),
}, nil
}