Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #156 from Strong-Potato/feature/#155-change-voting…
Browse files Browse the repository at this point in the history
…-request-url

[Feat] 투표 요청 URL 수정
  • Loading branch information
Dr-KoKo authored Jan 24, 2024
2 parents 5e024b8 + c00bdbf commit 291da6f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import fc.be.app.domain.vote.controller.dto.request.CandidateAddApiRequest;
import fc.be.app.domain.vote.controller.dto.request.CandidateDeleteApiRequest;
import fc.be.app.domain.vote.controller.dto.request.VoteCreateApiRequest;
import fc.be.app.domain.vote.controller.dto.request.VotingApiRequest;
import fc.be.app.domain.vote.service.dto.response.VoteDetailResponse;
import fc.be.app.domain.vote.service.dto.response.VoteResultResponse;
import fc.be.app.domain.vote.service.dto.response.VotesResponse;
Expand Down Expand Up @@ -119,6 +120,20 @@ ApiResponse<Void> deleteVote(
@AuthenticationPrincipal UserPrincipal userPrincipal
);

@Operation(
operationId = "voting",
summary = "투표를 진행하는 API",
description = "투표를 진행하는 API입니다. 투표를 취소할때도 동일한 URL로 요청합니다.",
security = {
@SecurityRequirement(name = "ACCESS_TOKEN", scopes = {"write:votes"})
}
)
@PostMapping("/voting")
ApiResponse<Void> voting(
@RequestBody @Valid VotingApiRequest request,
@AuthenticationPrincipal UserPrincipal userPrincipal
);

@Operation(
operationId = "delete candidates",
summary = "투표 후보 삭제하는 API",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import fc.be.app.domain.vote.controller.dto.request.CandidateAddApiRequest;
import fc.be.app.domain.vote.controller.dto.request.CandidateDeleteApiRequest;
import fc.be.app.domain.vote.controller.dto.request.VoteCreateApiRequest;
import fc.be.app.domain.vote.controller.dto.request.VotingApiRequest;
import fc.be.app.domain.vote.service.dto.request.CandidateAddRequest;
import fc.be.app.domain.vote.service.dto.request.CandidateDeleteRequest;
import fc.be.app.domain.vote.service.dto.request.VoteCreateRequest;
Expand Down Expand Up @@ -130,13 +131,12 @@ public ApiResponse<Void> resetVote(
return ApiResponse.ok();
}

@PostMapping("/{voteId}/candidates/{candidateId}")
@PostMapping("/voting")
public ApiResponse<Void> voting(
@PathVariable Long voteId,
@PathVariable Long candidateId,
@RequestBody @Valid VotingApiRequest request,
@AuthenticationPrincipal UserPrincipal userPrincipal
) {
votingService.voteOrCancel(new VotingRequest(voteId, userPrincipal.id(), candidateId));
votingService.voteOrCancel(new VotingRequest(request.voteId(), userPrincipal.id(), request.candidateId()));
return ApiResponse.ok();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package fc.be.app.domain.vote.controller.dto.request;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;

public record VotingApiRequest(
@Positive @NotNull Long voteId,
@Positive @NotNull Long candidateId
) {
}

0 comments on commit 291da6f

Please sign in to comment.