Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 이미 투표한 토픽에 투표할 때 exception #135

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

melonturtle
Copy link
Contributor

@melonturtle melonturtle commented Jan 15, 2024

What is this PR? 🔍

  • 이미 투표한 토픽에 투표할 때 exception

🛠️ Issue

Changes 📝

  • 기존에 DuplicateVote라는 네이밍이 이미 투표한 토픽에 투표해서 중복인지, 투표 수정 시 같은 선택지로 투표해서 중복인지 모호해서 둘 다 구체화
  • checkTopicVotable이 vote modify시에도 사용되고 있었는데, votable이면 투표 수정이 아니라 투표를 할 수 있는지 체크하는 게 맞는 것 같아서, votable과 modifiable 판단하는 메서드 나눔
checkTopicVotable 
 ├──> checkMemberVotableForTopic → checkTopicVotable → 투표하기 조건 체크
 └──> checkVoteModifiable        → checkTopicVotable → 투표 다시하기 조건 체크
  • vote, modify 메서드 전마다 check 메서드가 항상 있어야해서 전후관계가 생기므로 check 메서드를 vote, modify 메서드 내부로 이동
  • 클라이언트에서 필요할 수도 있을 것 같아서 exception에 paylod에 choice option 응답

To Reviewers 📢

  • 위 Changes 내용대로 투표 다시하기 부분도 좀 수정했습니다~~

에외처리, 네이밍 구체화

Issue: #102
@melonturtle melonturtle requested a review from 60jong January 15, 2024 02:40

deleteVotersComments(vote.getVoter(), vote.getTopic());

vote.changeOption(modifiedOption, modifiedAt);
}

private void checkVoteModifiable(Vote vote, ChoiceOption modifiedOption, LocalDateTime modifiedAt) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

vote modifiable / votable 구분하니 코드 이해가 수월한 것 같습니다:)

@60jong 60jong merged commit 31e651e into main Jan 16, 2024
1 check passed
@60jong 60jong deleted the duplicate-vote branch January 16, 2024 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

중복 투표 issue
2 participants