Class NotificationController
java.lang.Object
fr.utc.miage.sporttrack.controller.NotificationController
Spring MVC controller for notification management.
Provides endpoints for listing, opening, and marking notifications as read for the authenticated athlete.
- Author:
- SportTrack Team
-
Constructor Summary
ConstructorsConstructorDescriptionNotificationController(NotificationService notificationService, AthleteRepository athleteRepository) Constructs aNotificationControllerwith the required dependencies. -
Method Summary
Modifier and TypeMethodDescriptionlistNotifications(jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model) Lists all notifications for the authenticated athlete with an unread count.markAllAsRead(jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Marks all notifications as read for the authenticated athlete.markAsRead(Integer id, jakarta.servlet.http.HttpSession session) Marks a single notification as read.openNotification(Integer id, jakarta.servlet.http.HttpSession session) Opens a notification, marking it as read and redirecting to its target URL.
-
Constructor Details
-
NotificationController
public NotificationController(NotificationService notificationService, AthleteRepository athleteRepository) Constructs aNotificationControllerwith the required dependencies.- Parameters:
notificationService- the notification serviceathleteRepository- the athlete repository
-
-
Method Details
-
listNotifications
@GetMapping public String listNotifications(jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model) Lists all notifications for the authenticated athlete with an unread count.- Parameters:
session- the HTTP session for athlete resolutionmodel- the Spring MVC model- Returns:
- the view name "notification/list", or a redirect to login
-
openNotification
@GetMapping("/open/{id}") public String openNotification(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session) Opens a notification, marking it as read and redirecting to its target URL.- Parameters:
id- the notification identifiersession- the HTTP session for athlete resolution- Returns:
- a redirect to the notification target URL or the notification list
-
markAsRead
@PostMapping("/{id}/read") public String markAsRead(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session) Marks a single notification as read.- Parameters:
id- the notification identifiersession- the HTTP session for athlete resolution- Returns:
- a redirect to the notification list
-
markAllAsRead
@PostMapping("/read-all") public String markAllAsRead(jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Marks all notifications as read for the authenticated athlete.- Parameters:
session- the HTTP session for athlete resolutionredirectAttributes- flash attributes for success messaging- Returns:
- a redirect to the notification list
-