add getAllDrivers method

This commit is contained in:
2024-11-29 11:44:14 +01:00
parent f19ecbb2b4
commit b8e017b081
13 changed files with 707 additions and 504 deletions

View File

@@ -168,6 +168,29 @@ func (s *SolidarityServiceServerImpl) SetDriverPunctualAvailabilities(ctx contex
}, nil
}
func (s *SolidarityServiceServerImpl) GetAllDrivers( ctx context.Context, _ *emptypb.Empty) (resp *proto.GetAllDriversResponse, err error) {
drivers, err := s.Handler.GetAllDrivers(context.Background())
resp = &proto.GetAllDriversResponse{
DriverJourneys: []*proto.User{},
}
response := []*proto.User{}
for _, v := range drivers {
temp := &proto.User{
Id: v.Driver.ID,
Alias: v.Driver.Alias,
FirstName: v.Driver.FirstName,
LastName: v.Driver.LastName,
Grade: v.Driver.Grade,
Picture: v.Driver.Picture,
Gender: v.Driver.Gender,
VerifiedIdentity: v.Driver.VerifiedIdentity,
}
response = append(response, temp)
}
resp.DriverJourneys = response
return resp, nil
}
func (s *SolidarityServiceServerImpl) GetAllPassengers( ctx context.Context, _ *emptypb.Empty) (resp *proto.GetAllPassengersResponse, err error) {
passengers, err := s.Handler.GetAllPassengers(context.Background())
resp = &proto.GetAllPassengersResponse{
@@ -245,7 +268,7 @@ func (s *SolidarityServiceServerImpl) CreateBookingSolidarity(ctx context.Contex
},
Pickup_date: req.Booking.PickupDate.Seconds,
}
driver, err := s.Handler.CreateBooking(context.Background(), bookingRequest) //passenger,
passenger, driver, err := s.Handler.CreateBooking(context.Background(), bookingRequest)
if err != nil {
if strings.Contains(err.Error(), utils.SQL_DUPLICATE) {
err = errors.New("ID is already used")
@@ -275,7 +298,14 @@ func (s *SolidarityServiceServerImpl) CreateBookingSolidarity(ctx context.Contex
},
Passenger: &proto.User{
Id: req.Booking.PassengerId,
},
Alias: passenger.Passenger.Alias,
FirstName: passenger.Passenger.FirstName,
LastName: passenger.Passenger.LastName,
Grade: passenger.Passenger.Grade,
Picture: passenger.Passenger.Picture,
Gender: passenger.Passenger.Gender,
VerifiedIdentity: passenger.Passenger.VerifiedIdentity,
},
PassengerPickupDate: &timestamp.Timestamp{
Seconds: bookingRequest.Pickup_date,
},
@@ -359,6 +389,13 @@ func (s *SolidarityServiceServerImpl) GetBookingSolidarity(ctx context.Context,
},
Passenger: &proto.User{
Id: booking.Passenger.ID,
Alias: booking.Passenger.Alias,
FirstName: booking.Passenger.FirstName,
LastName: booking.Passenger.LastName,
Grade: booking.Passenger.Grade,
Picture: booking.Passenger.Picture,
Gender: booking.Passenger.Gender,
VerifiedIdentity: booking.Passenger.VerifiedIdentity,
},
PassengerPickupDate: &timestamp.Timestamp{
Seconds: booking.Pickup_date,