Package app.YUP.controller
Class ReservationController
java.lang.Object
app.YUP.controller.ReservationController
This class is a controller for handling reservation related requests.
It provides endpoints for creating a new reservation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Integer> checkQrCode(Map<String, String> payload, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) This method is used to check the reservation of a participant.deleteReservation(UUID eventId, UUID userId, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) This method is used to delete a reservation.myReservation(org.springframework.ui.Model model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) This method is used to retrieve all the reservations made by the user.newReservation(ReservationRequest reservationRequest, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) This method is used to create a new reservation.
-
Constructor Details
-
ReservationController
public ReservationController()
-
-
Method Details
-
newReservation
@PostMapping("/newReservation") public String newReservation(@ModelAttribute ReservationRequest reservationRequest, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException This method is used to create a new reservation. It takes a ReservationRequest object and a HttpServletRequest object as parameters. It uses the AuthenticationService to get the username from the cookie in the request. It then uses the ReservationService to create a new reservation. It also generates a QR code for the reservation and sends an email to the user with the details of the reservation.- Parameters:
reservationRequest- This is a request object that contains the details of the reservation to be created.request- This is the HttpServletRequest object that contains the request details.- Returns:
- String This returns a redirect URL to the reservations page.
- Throws:
IOException- This exception is thrown if there is an error while generating the QR code or sending the email.
-
deleteReservation
@PostMapping("api/delete") public String deleteReservation(@RequestParam UUID eventId, @RequestParam UUID userId, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) This method is used to delete a reservation. It takes an eventId as a parameter, a HttpServletRequest object, and a HttpServletResponse object. It uses the AuthenticationService to get the user ID from the cookie in the request. It then uses the ReservationService to delete the reservation for the given eventId and user. It sets the response status to OK. Finally, it returns a redirect URL to the myReservations page.- Parameters:
eventId- The unique identifier of the event for which the reservation needs to be deleted.request- The HttpServletRequest object that contains the request details.response- The HttpServletResponse object that can be used to set the response details.- Returns:
- String This returns a redirect URL to the myReservations page.
-
myReservation
@GetMapping("/myReservations") public String myReservation(org.springframework.ui.Model model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) This method is used to retrieve all the reservations made by the user. It takes a Model object, a HttpServletRequest object, and a HttpServletResponse object as parameters. It uses the AuthenticationService to get the user ID from the cookie in the request. It then uses the ReservationService to get all events reserved by the user. It sets the list of events and the user's first name as attributes to the request and model respectively. It also sets the response status to OK. Finally, it returns the name of the view to be rendered, in this case, "myAgenda".- Parameters:
model- This is the Model object that can be used to add attributes to the model.request- This is the HttpServletRequest object that contains the request details.response- This is the HttpServletResponse object that can be used to set the response details.- Returns:
- String This returns the name of the view to be rendered.
-
checkQrCode
@PostMapping("/checkQrCode") public org.springframework.http.ResponseEntity<Integer> checkQrCode(@RequestBody Map<String, String> payload, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) This method is used to check the reservation of a participant. It takes a payload containing the event ID and the QR code message, a HttpServletRequest object, and a HttpServletResponse object as parameters. It uses the AuthenticationService to get the user ID from the cookie in the request. It then uses the ReservationService to update the presence of the participant based on the QR code message. The method returns a ResponseEntity containing the number of affected rows.- Parameters:
payload- This is a payload containing the event ID and the QR code message.request- This is the HttpServletRequest object that contains the request details.response- This is the HttpServletResponse object that can be used to set the response details.- Returns:
- ResponseEntity This returns a ResponseEntity containing the number of affected rows.
-