Class AthleteActivityController

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

@Controller @RequestMapping("/athlete/activities") public class AthleteActivityController extends Object
Spring MVC controller for athlete activity management.

Provides endpoints for listing, creating, editing, and deleting the authenticated athlete's own activities, including automatic weather report fetching and badge award checks.

Author:
SportTrack Team
  • Constructor Summary

    Constructors
    Constructor
    Description
    AthleteActivityController(ActivityService activityService, SportService sportService, WeatherReportService weatherReportService, AthleteService athleteService, BadgeService badgeService, CommentService commentService)
    Constructs an AthleteActivityController with the required services.
  • Method Summary

    Modifier and Type
    Method
    Description
    deleteActivity(int id, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, org.springframework.security.core.Authentication auth)
    Deletes an activity owned by the authenticated athlete.
    listMyActivities(org.springframework.ui.Model model, org.springframework.security.core.Authentication auth)
    Lists all activities of the authenticated athlete with weather and comment data.
    saveActivity(ActivityFormDTO activity, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, org.springframework.security.core.Authentication auth)
    Creates or updates an activity from the submitted form data.
    showCreateForm(org.springframework.ui.Model model, org.springframework.security.core.Authentication auth)
    Displays the form for creating a new activity.
    showEditForm(int id, org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, org.springframework.security.core.Authentication auth)
    Displays the form for editing an existing activity owned by the current athlete.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AthleteActivityController

      public AthleteActivityController(ActivityService activityService, SportService sportService, WeatherReportService weatherReportService, AthleteService athleteService, BadgeService badgeService, CommentService commentService)
      Constructs an AthleteActivityController with the required services.
      Parameters:
      activityService - the activity service
      sportService - the sport service
      weatherReportService - the weather report service
      athleteService - the athlete service
      badgeService - the badge service
      commentService - the comment service
  • Method Details

    • listMyActivities

      @GetMapping public String listMyActivities(org.springframework.ui.Model model, org.springframework.security.core.Authentication auth)
      Lists all activities of the authenticated athlete with weather and comment data.
      Parameters:
      model - the Spring MVC model
      auth - the current security authentication
      Returns:
      the view name "athlete/activity/list", or a redirect to login
    • showCreateForm

      @GetMapping("/create") public String showCreateForm(org.springframework.ui.Model model, org.springframework.security.core.Authentication auth)
      Displays the form for creating a new activity.
      Parameters:
      model - the Spring MVC model
      auth - the current security authentication
      Returns:
      the view name "athlete/activity/create", or a redirect to login
    • showEditForm

      @GetMapping("/edit/{id}") public String showEditForm(@PathVariable int id, org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, org.springframework.security.core.Authentication auth)
      Displays the form for editing an existing activity owned by the current athlete.
      Parameters:
      id - the activity identifier
      model - the Spring MVC model
      redirectAttributes - flash attributes for error messaging
      auth - the current security authentication
      Returns:
      the view name "athlete/activity/create", or a redirect on failure
    • saveActivity

      @PostMapping("/save") public String saveActivity(@ModelAttribute("activity") ActivityFormDTO activity, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, org.springframework.security.core.Authentication auth)
      Creates or updates an activity from the submitted form data. After saving, triggers weather report refresh and badge award checks.
      Parameters:
      activity - the form DTO containing the activity data
      redirectAttributes - flash attributes for success/error messaging
      auth - the current security authentication
      Returns:
      a redirect to the activity list, create, or edit page
    • deleteActivity

      @PostMapping("/delete/{id}") public String deleteActivity(@PathVariable int id, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, org.springframework.security.core.Authentication auth)
      Deletes an activity owned by the authenticated athlete.
      Parameters:
      id - the activity identifier to delete
      redirectAttributes - flash attributes for success/error messaging
      auth - the current security authentication
      Returns:
      a redirect to the activity list