Class NotificationController

java.lang.Object
fr.utc.miage.sporttrack.controller.NotificationController

@Controller @RequestMapping("/notifications") public class NotificationController extends Object
Spring MVC controller for notification management.

Provides endpoints for listing, opening, and marking notifications as read for the authenticated athlete.

Author:
SportTrack Team
  • Constructor Details

    • NotificationController

      public NotificationController(NotificationService notificationService, AthleteRepository athleteRepository)
      Constructs a NotificationController with the required dependencies.
      Parameters:
      notificationService - the notification service
      athleteRepository - 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 resolution
      model - 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 identifier
      session - 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 identifier
      session - 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 resolution
      redirectAttributes - flash attributes for success messaging
      Returns:
      a redirect to the notification list