Package vaultWeb.controllers
Class PollController
java.lang.Object
vaultWeb.controllers.PollController
@RestController
@RequestMapping("/groups/{groupId}/polls")
public class PollController
extends Object
Controller for managing polls within a specific group. All endpoints are prefixed with
/groups/{groupId}/polls.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<PollResponseDto> createPoll(Long groupId, @Valid PollRequestDto pollDto) Creates a new poll in the specified group.org.springframework.http.ResponseEntity<Void> deletePoll(Long groupId, Long pollId) Deletes a poll from a group.org.springframework.http.ResponseEntity<List<PollResponseDto>> Retrieves all polls of a given group.org.springframework.http.ResponseEntity<PollResponseDto> updatePoll(Long groupId, Long pollId, @Valid PollRequestDto pollDto) Updates an existing poll.org.springframework.http.ResponseEntity<Void> Casts a vote for a specific poll option.
-
Constructor Details
-
PollController
public PollController()
-
-
Method Details
-
createPoll
@PostMapping("") public org.springframework.http.ResponseEntity<PollResponseDto> createPoll(@PathVariable Long groupId, @RequestBody @Valid @Valid PollRequestDto pollDto) Creates a new poll in the specified group.- Parameters:
groupId- the ID of the group where the poll will be createdpollDto- the poll data sent in the request body- Returns:
- the created poll as a PollResponseDto
-
getPolls
@GetMapping("") public org.springframework.http.ResponseEntity<List<PollResponseDto>> getPolls(@PathVariable Long groupId) Retrieves all polls of a given group.- Parameters:
groupId- the ID of the group- Returns:
- list of PollResponseDto objects
-
vote
@PostMapping("/{pollId}/options/{optionId}/vote") public org.springframework.http.ResponseEntity<Void> vote(@PathVariable Long groupId, @PathVariable Long pollId, @PathVariable Long optionId) Casts a vote for a specific poll option.- Parameters:
groupId- the ID of the grouppollId- the ID of the polloptionId- the ID of the option being voted for- Returns:
- HTTP 204 No Content
-
updatePoll
@PutMapping("/{pollId}") public org.springframework.http.ResponseEntity<PollResponseDto> updatePoll(@PathVariable Long groupId, @PathVariable Long pollId, @RequestBody @Valid @Valid PollRequestDto pollDto) Updates an existing poll.- Parameters:
groupId- the ID of the grouppollId- the ID of the poll to updatepollDto- the new poll data- Returns:
- updated PollResponseDto
-
deletePoll
@DeleteMapping("/{pollId}") public org.springframework.http.ResponseEntity<Void> deletePoll(@PathVariable Long groupId, @PathVariable Long pollId) Deletes a poll from a group.- Parameters:
groupId- the ID of the grouppollId- the ID of the poll to delete- Returns:
- HTTP 204 No Content
-