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
674 B
30 lines
674 B
2 years ago
|
package service
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
v1 "map/api/helloworld/v1"
|
||
|
"map/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
|
||
|
}
|