Class FriendshipController
java.lang.Object
fr.utc.miage.sporttrack.controller.FriendshipController
Spring MVC controller for friendship-related pages and actions.
Manages friend listing, sending/accepting/rejecting friend requests, removing friends, blocking/unblocking users, and viewing friend profiles with their activities.
- Author:
- SportTrack Team
-
Constructor Summary
ConstructorsConstructorDescriptionFriendshipController(FriendshipService friendshipService, FriendshipRepository friendshipRepository, AthleteRepository athleteRepository, AthleteService athleteService, ActivityService activityService, WeatherReportService weatherReportService, BadgeService badgeService, CommentService commentService) Constructs aFriendshipControllerwith the required dependencies. -
Method Summary
Modifier and TypeMethodDescriptionacceptFriendRequest(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Accepts a pending friend request.blockUser(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Blocks another user.friendProfile(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model) Shows a friend's profile page with relationship status.friendsActivities(jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model) Shows the aggregated activity feed for all accepted friends.friendsPage(jakarta.servlet.http.HttpSession session, String query, String tab, org.springframework.ui.Model model) Shows the main friendship management page with 5 tabs.rejectFriendRequest(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Rejects a pending friend request.removeFriend(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Removes an established friendship.sendFriendRequest(jakarta.servlet.http.HttpSession session, Integer recipientId, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Sends a friend request to another athlete.unblockUser(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Unblocks a previously blocked user.
-
Constructor Details
-
FriendshipController
public FriendshipController(FriendshipService friendshipService, FriendshipRepository friendshipRepository, AthleteRepository athleteRepository, AthleteService athleteService, ActivityService activityService, WeatherReportService weatherReportService, BadgeService badgeService, CommentService commentService) Constructs aFriendshipControllerwith the required dependencies.- Parameters:
friendshipService- the friendship servicefriendshipRepository- the friendship repositoryathleteRepository- the athlete repositoryathleteService- the athlete serviceactivityService- the activity serviceweatherReportService- the weather report servicebadgeService- the badge servicecommentService- the comment service
-
-
Method Details
-
friendsPage
@GetMapping("/friends") public String friendsPage(jakarta.servlet.http.HttpSession session, @RequestParam(name="q",required=false) String query, @RequestParam(name="tab",required=false) String tab, org.springframework.ui.Model model) Shows the main friendship management page with 5 tabs. Loads all data at once for all tabs.- Parameters:
session- the current HTTP sessionquery- optional search query for the "Add friend" tabtab- optional tab identifier to activatemodel- the model used by the view template- Returns:
- the friends view or a redirect to login
-
friendProfile
@GetMapping("/friends/profile/{id}") public String friendProfile(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model) Shows a friend's profile page with relationship status.- Parameters:
id- the ID of the athlete to viewsession- the current HTTP sessionmodel- the model used by the view template- Returns:
- the profile view or a redirect to login
-
friendsActivities
@GetMapping("/friends/activities") public String friendsActivities(jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model) Shows the aggregated activity feed for all accepted friends. -
sendFriendRequest
@PostMapping("/friends/send") public String sendFriendRequest(jakarta.servlet.http.HttpSession session, @RequestParam("recipientId") Integer recipientId, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Sends a friend request to another athlete. -
acceptFriendRequest
@PostMapping("/friends/accept/{id}") public String acceptFriendRequest(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Accepts a pending friend request. -
rejectFriendRequest
@PostMapping("/friends/reject/{id}") public String rejectFriendRequest(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Rejects a pending friend request. -
removeFriend
@PostMapping("/friends/remove/{id}") public String removeFriend(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Removes an established friendship. -
blockUser
@PostMapping("/friends/block/{id}") public String blockUser(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Blocks another user. -
unblockUser
@PostMapping("/friends/unblock/{id}") public String unblockUser(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Unblocks a previously blocked user.
-