Feature/#2 투표 토글 및 투표 개수 조회 api 구현#61
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a full “team vote” feature: toggling votes per team within a contest and querying a member’s remaining vote capacity, along with persistence, service, controller, tests, and API documentation.
Changes:
- Added
TeamVotedomain model, repository, and schema table, plus aTeamVoteCommandServiceand securedTeamVoteControllerexposing vote-toggle and member-vote-count endpoints. - Implemented exception types (
TeamVoteExceptionType,TeamVoteException) and contest voting-period validation, and wired them into new and existing convenience layers. - Added comprehensive integration tests, RestDocs-based API tests, and Asciidoc documentation for the new team vote APIs, including updates to shared fixtures and the API index.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/opus/opus/team/application/TeamVoteCommandServiceTest.java | Integration tests covering vote toggling behavior, limits, and member vote-count semantics. |
| src/test/java/com/opus/opus/team/TeamVoteFixture.java | Test fixture for creating TeamVote entities with configurable team, memberId, and isVoted flag. |
| src/test/java/com/opus/opus/team/TeamFixture.java | Extended team fixture to support creating teams for a given contest, used by vote tests. |
| src/test/java/com/opus/opus/restdocs/docs/TeamVoteApiDocsTest.java | RestDocs tests documenting success and error scenarios for vote toggle and member vote-count endpoints (one set of description constants currently unused). |
| src/test/java/com/opus/opus/restdocs/RestDocsTest.java | Included TeamVoteController in the WebMvc slice and added a mock TeamVoteCommandService for RestDocs. |
| src/main/resources/schema.sql | Added team_vote DDL and ensured it’s dropped/created alongside other team-related tables. |
| src/main/java/com/opus/opus/modules/team/exception/TeamVoteExceptionType.java | Defined vote-specific error types (already voted/unvoted, vote limit exceeded) with HTTP mappings and messages. |
| src/main/java/com/opus/opus/modules/team/exception/TeamVoteException.java | Exception wrapper for TeamVoteExceptionType, consistent with other module exceptions. |
| src/main/java/com/opus/opus/modules/team/domain/dao/TeamVoteRepository.java | Repository for TeamVote with methods to find a member’s vote for a team and count active votes per contest. |
| src/main/java/com/opus/opus/modules/team/domain/dao/TeamCommentRepository.java | Removed unused deleteAllByTeamId to simplify the comment repository interface. |
| src/main/java/com/opus/opus/modules/team/domain/TeamVote.java | New JPA entity representing a member’s vote on a team, linked to Team and tracking isVoted. |
| src/main/java/com/opus/opus/modules/team/domain/Team.java | Added a teamVotes collection to model the one-to-many relation from team to votes. |
| src/main/java/com/opus/opus/modules/team/application/dto/response/TeamVoteToggleResponse.java | Response DTO for toggle operations, including derived remaining-vote count and max limit. |
| src/main/java/com/opus/opus/modules/team/application/dto/response/MemberVoteCountResponse.java | DTO returning a member’s remaining vote slots and the contest’s max vote limit. |
| src/main/java/com/opus/opus/modules/team/application/dto/request/TeamVoteToggleRequest.java | Request DTO for toggling a vote with a mandatory isVoted flag. |
| src/main/java/com/opus/opus/modules/team/application/TeamVoteCommandService.java | Core service implementing vote toggle logic, enforcing voting period and max-vote limits, and exposing member vote-count computation. |
| src/main/java/com/opus/opus/modules/team/api/TeamVoteController.java | Secured REST controller exposing PATCH /teams/{teamId}/votes and GET /teams/votes endpoints for vote toggling and member vote-count retrieval. |
| src/main/java/com/opus/opus/modules/contest/exception/ContestExceptionType.java | Added NOT_VOTE_PERIOD_NOW contest error to represent calls outside the permitted voting window. |
| src/main/java/com/opus/opus/modules/contest/application/convenience/ContestConvenience.java | Added validateVotingPeriod helper that throws when a contest is not in its voting period. |
| src/main/java/com/opus/opus/docs/asciidoc/team-vote.adoc | New Asciidoc page documenting team vote toggle and member vote-count APIs, including success and error cases (with a small mismatch in wording vs actual response semantics). |
| src/main/java/com/opus/opus/docs/asciidoc/opus.adoc | Linked the new team vote documentation page into the main API index. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/test/java/com/opus/opus/restdocs/docs/TeamVoteApiDocsTest.java
Outdated
Show resolved
Hide resolved
src/main/java/com/opus/opus/modules/team/application/TeamVoteCommandService.java
Outdated
Show resolved
Hide resolved
src/main/java/com/opus/opus/modules/contest/application/convenience/ContestConvenience.java
Outdated
Show resolved
Hide resolved
src/main/java/com/opus/opus/modules/team/api/TeamVoteController.java
Outdated
Show resolved
Hide resolved
src/main/java/com/opus/opus/modules/team/api/TeamVoteController.java
Outdated
Show resolved
Hide resolved
| @GetMapping("/votes") | ||
| public ResponseEntity<MemberVoteCountResponse> getMemberVoteCount( | ||
| @RequestParam Long contestId, | ||
| @LoginMember Member member) { | ||
| MemberVoteCountResponse response = teamVoteCommandService.getMemberVoteCount(member.getId(), contestId); | ||
| return ResponseEntity.ok(response); | ||
| } |
There was a problem hiding this comment.
저는 이 메서드의 위치가 조금 애매하다고 생각합니다
지금은 url이 teams 밑에 있는데 팀 하위 느낌이 아닌, 내가(contest에서)투표한 개수 조회라서 느낌이라서 어색한 것 같아요
그래서 태윤님도 RequestParam으로 contestId를 받고, commandService에서 Transactional을 수정한 것으로 보여요
제가 제안하는 수정 방안은 다음과 같습니다! 확인 부탁드려요
MemberController로 위치 이동
ORContest를 포함하도록url수정
There was a problem hiding this comment.
저도 사용자가 특정 대회에서 투표한 개수 조회인데 /teams 하우에 있으니 의미가 잘 안 맞는 거 같네요!
제안해주신 두 가지 방안 중에서 Contest를 포함하도록 URL을 수정하는 것이 더 적절해 보입니다. 특정 대회에서의 사용자의 현재 투표 현황을 조회하는 것이기 때문에요! /contests/{contestId}/votes/me와 같은 형태로 수정하고 ContestController로 이동시켜도 될까요-?
++ 추가적으로 저번에 CRUD가 모두 포함되는게 아니라면 따로 Controller를 굳이 만들지 말자고 했던 거 같은데요! 이번에도 리뷰해주신 메서드를 빼내게 되면 투표 토글 API 한 개만 남는데 이 또한 TeamController로 이동시키는게 어떨까요-??
There was a problem hiding this comment.
확인했습니다~! 추가로 작성해주신 Controller 이동도 좋은 것 같아요!
src/main/java/com/opus/opus/modules/team/application/TeamVoteCommandService.java
Show resolved
Hide resolved
src/main/java/com/opus/opus/modules/team/application/TeamVoteCommandService.java
Outdated
Show resolved
Hide resolved
src/test/java/com/opus/opus/team/application/TeamVoteCommandServiceTest.java
Show resolved
Hide resolved
sjmoon00
left a comment
There was a problem hiding this comment.
잘 구현하신것 같습니다~
리뷰 확인 부탁드립니다!
🔥 연관된 이슈
close: #2
📜 작업 내용
💬 리뷰 요구사항
✨ 기타