Skip to content

Commit

Permalink
fix: 요구 사항에 맞게 멤버 티켓 검증 수정 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
khabh authored Nov 3, 2024
1 parent f5ee5ea commit 47659b9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
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

0 comments on commit 47659b9

Please sign in to comment.