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
ConstructorsConstructorDescriptionAdminActivityController(ActivityService activityService, SportService sportService, WeatherReportService weatherReportService, AdminService adminService) Constructs anAdminActivityControllerwith the required services. -
Method Summary
Modifier and TypeMethodDescriptiondeleteActivity(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.
-
Constructor Details
-
AdminActivityController
public AdminActivityController(ActivityService activityService, SportService sportService, WeatherReportService weatherReportService, AdminService adminService) Constructs anAdminActivityControllerwith the required services.- Parameters:
activityService- the activity servicesportService- the sport serviceweatherReportService- the weather report serviceadminService- 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 modelauth- 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 identifiermodel- the Spring MVC modelredirectAttributes- flash attributes for error messagingauth- 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 dataredirectAttributes- flash attributes for success/error messagingauth- 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 deleteredirectAttributes- flash attributes for success/error messagingauth- the current security authentication- Returns:
- a redirect to the activity list
-