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

fix: 요구 사항에 맞게 멤버 티켓 검증 수정 #9

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import com.aengdulab.ticket.domain.Member;
import com.aengdulab.ticket.domain.MemberTicket;
import com.aengdulab.ticket.domain.Ticket;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface MemberTicketRepository extends JpaRepository<MemberTicket, Long> {

int countByMemberAndTicket(Member member, Ticket ticket);
int countByMember(Member member);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void validateIssuable(Member member, Ticket ticket) {
if (!ticket.issuable()) {
throw new IllegalArgumentException("티켓 재고가 소진되었습니다.");
}
int issuedMemberTicketCount = memberTicketRepository.countByMemberAndTicket(member, ticket);
int issuedMemberTicketCount = memberTicketRepository.countByMember(member);
if (issuedMemberTicketCount >= MemberTicket.MEMBER_TICKET_COUNT_MAX) {
throw new IllegalArgumentException("계정당 구매할 수 있는 티켓 수량을 넘었습니다.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void setUp() {
latch.await();

for (Member member : members) {
long issuedTicketCount = memberTicketRepository.countByMemberAndTicket(member, ticket);
long issuedTicketCount = memberTicketRepository.countByMember(member);
assertThat(issuedTicketCount).isEqualTo(MemberTicket.MEMBER_TICKET_COUNT_MAX);
}

Expand Down