Class AdminActivityController

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

@Controller @RequestMapping("/admin/activities") public class AdminActivityController extends Object
Spring MVC controller for administrator activity management.

Provides endpoints for listing, editing, and deleting any activity in the system. Activity creation is reserved for athletes.

Author:
SportTrack Team
  • Constructor Summary

    Constructors
    Constructor
    Description
    AdminActivityController(ActivityService activityService, SportService sportService, WeatherReportService weatherReportService, AdminService adminService)
    Constructs an AdminActivityController 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 the activity with the given identifier.
    listActivities(org.springframework.ui.Model model, org.springframework.security.core.Authentication auth)
    Lists all activities in the system for the admin dashboard.
    saveActivity(ActivityFormDTO activity, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, org.springframework.security.core.Authentication auth)
    Updates an existing activity from the submitted form data.
    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.

    Methods inherited from class java.lang.Object

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

    • AdminActivityController

      public AdminActivityController(ActivityService activityService, SportService sportService, WeatherReportService weatherReportService, AdminService adminService)
      Constructs an AdminActivityController with the required services.
      Parameters:
      activityService - the activity service
      sportService - the sport service
      weatherReportService - the weather report service
      adminService - the admin service
  • Method Details

    • listActivities

      @GetMapping public String listActivities(org.springframework.ui.Model model, org.springframework.security.core.Authentication auth)
      Lists all activities in the system for the admin dashboard.
      Parameters:
      model - the Spring MVC model
      auth - the current security authentication
      Returns:
      the view name "admin/activity/list", 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.
      Parameters:
      id - the activity identifier
      model - the Spring MVC model
      redirectAttributes - flash attributes for error messaging
      auth - the current security authentication
      Returns:
      the edit view, 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)
      Updates an existing activity from the submitted form data. Activity creation is not allowed for admins; only updates are supported.
      Parameters:
      activity - the form DTO containing the updated activity data
      redirectAttributes - flash attributes for success/error messaging
      auth - the current security authentication
      Returns:
      a redirect to the activity list or edit form on error
    • 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 the activity with the given identifier.
      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