diff --git a/ticket/src/main/java/com/aengdulab/ticket/repository/MemberTicketRepository.java b/ticket/src/main/java/com/aengdulab/ticket/repository/MemberTicketRepository.java index 97f49c7..0339d71 100644 --- a/ticket/src/main/java/com/aengdulab/ticket/repository/MemberTicketRepository.java +++ b/ticket/src/main/java/com/aengdulab/ticket/repository/MemberTicketRepository.java @@ -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 { - int countByMemberAndTicket(Member member, Ticket ticket); + int countByMember(Member member); } diff --git a/ticket/src/main/java/com/aengdulab/ticket/service/MemberTicketService.java b/ticket/src/main/java/com/aengdulab/ticket/service/MemberTicketService.java index 85f77c9..f754a6b 100644 --- a/ticket/src/main/java/com/aengdulab/ticket/service/MemberTicketService.java +++ b/ticket/src/main/java/com/aengdulab/ticket/service/MemberTicketService.java @@ -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("계정당 구매할 수 있는 티켓 수량을 넘었습니다."); } diff --git a/ticket/src/test/java/com/aengdulab/ticket/service/MemberTicketServiceConcurrencyTest.java b/ticket/src/test/java/com/aengdulab/ticket/service/MemberTicketServiceConcurrencyTest.java index 81078ab..c1a7064 100644 --- a/ticket/src/test/java/com/aengdulab/ticket/service/MemberTicketServiceConcurrencyTest.java +++ b/ticket/src/test/java/com/aengdulab/ticket/service/MemberTicketServiceConcurrencyTest.java @@ -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); }