Skip to content

Feature/#2 투표 토글 및 투표 개수 조회 api 구현#61

Open
pykido wants to merge 6 commits intodevelopfrom
Feature/#2-투표_토글_및_투표_개수_조회_API_구현

Hidden character warning

The head ref may contain hidden characters: "Feature/#2-\ud22c\ud45c_\ud1a0\uae00_\ubc0f_\ud22c\ud45c_\uac1c\uc218_\uc870\ud68c_API_\uad6c\ud604"
Open

Feature/#2 투표 토글 및 투표 개수 조회 api 구현#61
pykido wants to merge 6 commits intodevelopfrom
Feature/#2-투표_토글_및_투표_개수_조회_API_구현

Conversation

@pykido
Copy link
Contributor

@pykido pykido commented Jan 26, 2026

🔥 연관된 이슈

close: #2

📜 작업 내용

  • 팀 투표 토글 및 투표 개수 조회 API를 구현하였습니다.
  • 댓글 CRUD API를 구현했을 때와 비슷하게 개발하였습니다.
  • 기존 MVP에서 구현한 '좋아요' 기능이 '팀 투표' 기능으로 바뀌었기에 해당 로직들을 조금 손 보아 마이그레이션하였습니다.

💬 리뷰 요구사항

  • 항상 좋은 리뷰 감사드립니다!

✨ 기타

  • 화이팅!!

@pykido pykido self-assigned this Jan 26, 2026
@pykido pykido added the ⭐️ 기능 구현 새로운 기능을 구현 label Jan 26, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TeamVote domain model, repository, and schema table, plus a TeamVoteCommandService and secured TeamVoteController exposing 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.

JJimini

This comment was marked as resolved.

Copy link
Collaborator

@JJimini JJimini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다! 전체적으로 final이 다 빠진 것 같아서 확인 부탁드립니다~
HTTP MethodAPI의 위치 등 같이 이야기 해보면 좋은 부분이 조금 있는 것 같아서 Request Changes로 남겨두겠습니다..!

Comment on lines 38 to 44
@GetMapping("/votes")
public ResponseEntity<MemberVoteCountResponse> getMemberVoteCount(
@RequestParam Long contestId,
@LoginMember Member member) {
MemberVoteCountResponse response = teamVoteCommandService.getMemberVoteCount(member.getId(), contestId);
return ResponseEntity.ok(response);
}
Copy link
Collaborator

@JJimini JJimini Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 이 메서드의 위치가 조금 애매하다고 생각합니다
지금은 url이 teams 밑에 있는데 팀 하위 느낌이 아닌, 내가(contest에서)투표한 개수 조회라서 느낌이라서 어색한 것 같아요

그래서 태윤님도 RequestParam으로 contestId를 받고, commandService에서 Transactional을 수정한 것으로 보여요

제가 제안하는 수정 방안은 다음과 같습니다! 확인 부탁드려요

  1. MemberController로 위치 이동
    OR
  2. Contest를 포함하도록 url 수정

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 사용자가 특정 대회에서 투표한 개수 조회인데 /teams 하우에 있으니 의미가 잘 안 맞는 거 같네요!
제안해주신 두 가지 방안 중에서 Contest를 포함하도록 URL을 수정하는 것이 더 적절해 보입니다. 특정 대회에서의 사용자의 현재 투표 현황을 조회하는 것이기 때문에요! /contests/{contestId}/votes/me와 같은 형태로 수정하고 ContestController로 이동시켜도 될까요-?

++ 추가적으로 저번에 CRUD가 모두 포함되는게 아니라면 따로 Controller를 굳이 만들지 말자고 했던 거 같은데요! 이번에도 리뷰해주신 메서드를 빼내게 되면 투표 토글 API 한 개만 남는데 이 또한 TeamController로 이동시키는게 어떨까요-??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다~! 추가로 작성해주신 Controller 이동도 좋은 것 같아요!

Copy link
Contributor

@sjmoon00 sjmoon00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

잘 구현하신것 같습니다~
리뷰 확인 부탁드립니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⭐️ 기능 구현 새로운 기능을 구현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 투표 토글 및 투표 개수 조회 API 구현

3 participants