File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
backend/src/main/java/com/ai/lawyer/domain/poll/controller Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,20 @@ public List<PollDto> getTopOngoingPolls(@RequestParam(defaultValue = "3") int si
132132 return pollService .getTopNPollsByStatus (PollDto .PollStatus .ONGOING , size );
133133 }
134134
135+ @ Operation (summary = "index(순번)로 투표하기 - Swagger 편의용" )
136+ @ PostMapping ("/{pollId}/vote-by-index" )
137+ public ResponseEntity <?> voteByIndex (@ PathVariable Long pollId , @ RequestParam int index ) {
138+ Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
139+ Long memberId = Long .parseLong (authentication .getName ());
140+
141+ List <PollOptions > options = pollService .getPollOptions (pollId );
142+ if (index < 1 || index > options .size ()) {
143+ throw new ResponseStatusException (org .springframework .http .HttpStatus .BAD_REQUEST , "index가 옵션 범위를 벗어났습니다." );
144+ }
145+ Long pollItemsId = options .get (index - 1 ).getPollItemsId ();
146+ return ResponseEntity .ok (pollService .vote (pollId , pollItemsId , memberId ));
147+ }
148+
135149 @ ExceptionHandler (ResponseStatusException .class )
136150 public ResponseEntity <Object > handleResponseStatusException (ResponseStatusException ex ) {
137151 int code = ex .getStatusCode ().value ();
You can’t perform that action at this time.
0 commit comments