package transport import ( "context" "git.sch9.ru/new_gate/ms-tester/internal/models" testerv1 "git.sch9.ru/new_gate/ms-tester/pkg/go/gen/tester/v1" "go.uber.org/zap" "google.golang.org/protobuf/types/known/timestamppb" "time" "google.golang.org/grpc" ) type ProblemService interface { CreateProblem(ctx context.Context, problem *models.Problem) (int32, error) ReadProblem(ctx context.Context, id int32) (*models.Problem, error) UpdateProblem(ctx context.Context, problem *models.Problem) error DeleteProblem(ctx context.Context, id int32) error } type TesterServer struct { testerv1.UnimplementedTesterServiceServer problemService ProblemService gRPCServer *grpc.Server logger *zap.Logger } func NewTesterServer(problemService ProblemService, gRPCServer *grpc.Server, logger *zap.Logger) *TesterServer { server := &TesterServer{ problemService: problemService, gRPCServer: gRPCServer, logger: logger, } testerv1.RegisterTesterServiceServer(gRPCServer, server) return server } func AsTimeP(t *timestamppb.Timestamp) *time.Time { if t == nil { return nil } tt := t.AsTime() return &tt } func AsTimestampP(t *time.Time) *timestamppb.Timestamp { if t == nil { return nil } return timestamppb.New(*t) }