Package vaultWeb.controllers
Class GroupController
java.lang.Object
vaultWeb.controllers.GroupController
Controller for managing groups within the application.
Provides endpoints to list public groups, get details of a group, manage group membership, and create, update, or delete groups. Some operations require the user to have admin privileges.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Group> createGroup(GroupDto groupDto) Creates a new group.org.springframework.http.ResponseEntity<Void> deleteGroup(Long id) Deletes a group.org.springframework.http.ResponseEntity<Group> getGroupById(Long id) Retrieves a group by its ID.getGroupMembers(Long id) Retrieves all members of a given group.Retrieves all public groups.org.springframework.http.ResponseEntity<Group> Current user joins a group.org.springframework.http.ResponseEntity<Group> leaveGroup(Long id) Current user leaves a group.org.springframework.http.ResponseEntity<Group> removeMemberFromGroup(Long groupId, Long userId) Removes a member from a group.org.springframework.http.ResponseEntity<Group> updateGroup(Long id, GroupDto updatedGroup) Updates a group.
-
Constructor Details
-
GroupController
public GroupController()
-
-
Method Details
-
getGroups
Retrieves all public groups.- Returns:
- a list of public groups
-
getGroupById
@GetMapping("/{id}") public org.springframework.http.ResponseEntity<Group> getGroupById(@PathVariable Long id) Retrieves a group by its ID.- Parameters:
id- the ID of the group- Returns:
- the group if found, or 404 if not found
-
getGroupMembers
@GetMapping("/{id}/members") public org.springframework.http.ResponseEntity<List<User>> getGroupMembers(@PathVariable Long id) Retrieves all members of a given group.- Parameters:
id- the ID of the group- Returns:
- a list of users in the group
-
createGroup
@PostMapping("") public org.springframework.http.ResponseEntity<Group> createGroup(@RequestBody GroupDto groupDto) Creates a new group.- Parameters:
groupDto- the data for the new group- Returns:
- the created group
-
joinGroup
@PostMapping("/{id}/join") public org.springframework.http.ResponseEntity<Group> joinGroup(@PathVariable Long id) Current user joins a group.- Parameters:
id- the ID of the group to join- Returns:
- the updated group
-
updateGroup
@PutMapping("/{id}") public org.springframework.http.ResponseEntity<Group> updateGroup(@PathVariable Long id, @RequestBody GroupDto updatedGroup) Updates a group. Admin privileges required.- Parameters:
id- the ID of the group to updateupdatedGroup- the updated group data- Returns:
- the updated group
-
deleteGroup
@DeleteMapping("/{id}") public org.springframework.http.ResponseEntity<Void> deleteGroup(@PathVariable Long id) Deletes a group. Admin privileges required.- Parameters:
id- the ID of the group to delete
-
leaveGroup
@DeleteMapping("/{id}/leave") public org.springframework.http.ResponseEntity<Group> leaveGroup(@PathVariable Long id) Current user leaves a group.- Parameters:
id- the ID of the group to leave- Returns:
- the updated group
-
removeMemberFromGroup
@DeleteMapping("/{groupId}/members/{userId}") public org.springframework.http.ResponseEntity<Group> removeMemberFromGroup(@PathVariable Long groupId, @PathVariable Long userId) Removes a member from a group. Admin privileges required.- Parameters:
groupId- the ID of the groupuserId- the ID of the user to remove- Returns:
- the updated group
-