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.
30 lines
688 B
30 lines
688 B
1 year ago
|
package service
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
v1 "verifyCode/api/helloworld/v1"
|
||
|
"verifyCode/internal/biz"
|
||
|
)
|
||
|
|
||
|
// GreeterService is a greeter service.
|
||
|
type GreeterService struct {
|
||
|
v1.UnimplementedGreeterServer
|
||
|
|
||
|
uc *biz.GreeterUsecase
|
||
|
}
|
||
|
|
||
|
// NewGreeterService new a greeter service.
|
||
|
func NewGreeterService(uc *biz.GreeterUsecase) *GreeterService {
|
||
|
return &GreeterService{uc: uc}
|
||
|
}
|
||
|
|
||
|
// SayHello implements helloworld.GreeterServer.
|
||
|
func (s *GreeterService) SayHello(ctx context.Context, in *v1.HelloRequest) (*v1.HelloReply, error) {
|
||
|
g, err := s.uc.CreateGreeter(ctx, &biz.Greeter{Hello: in.Name})
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return &v1.HelloReply{Message: "Hello " + g.Hello}, nil
|
||
|
}
|