generated from VLADIMIR/template
add get ticket
This commit is contained in:
@@ -5,11 +5,41 @@ import (
|
||||
|
||||
"evening_detective_server/internal/modules/processor_jwt"
|
||||
"evening_detective_server/internal/modules/roles"
|
||||
"evening_detective_server/internal/services/ticket_service"
|
||||
"evening_detective_server/proto"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
func (s *server) GetTicket(ctx context.Context, req *proto.GetTicketReq) (*proto.GetTicketRsp, error) {
|
||||
_ = grpc.SetHeader(ctx, metadata.Pairs("Cache-Control", "no-store"))
|
||||
if req == nil {
|
||||
return &proto.GetTicketRsp{Error: ticket_service.ErrTicketNotFound.Error()}, nil
|
||||
}
|
||||
page, err := s.ticketService.Get(ctx, req.Token)
|
||||
if err != nil {
|
||||
return &proto.GetTicketRsp{Error: ticket_service.ErrTicketNotFound.Error()}, nil
|
||||
}
|
||||
|
||||
result := &proto.TicketPage{
|
||||
Id: int32(page.ID),
|
||||
GameName: page.GameName,
|
||||
StartAt: timestamppb.New(page.StartAt),
|
||||
Status: page.Status,
|
||||
GameStatus: page.GameStatus,
|
||||
}
|
||||
if page.Location != nil {
|
||||
result.Location = *page.Location
|
||||
}
|
||||
if page.UsedAt != nil {
|
||||
result.UsedAt = timestamppb.New(*page.UsedAt)
|
||||
}
|
||||
return &proto.GetTicketRsp{Ticket: result}, nil
|
||||
}
|
||||
|
||||
func (s *server) IssueGameTickets(ctx context.Context, req *proto.IssueGameTicketsReq) (*proto.IssueGameTicketsRsp, error) {
|
||||
claims, ok := ctx.Value("claims").(*processor_jwt.JWTClaims)
|
||||
if !ok || claims == nil {
|
||||
|
||||
Reference in New Issue
Block a user