diff --git a/src/main/java/com/beat/domain/booking/dao/BookingRepository.java b/src/main/java/com/beat/domain/booking/dao/BookingRepository.java index 111be517..cd12d617 100644 --- a/src/main/java/com/beat/domain/booking/dao/BookingRepository.java +++ b/src/main/java/com/beat/domain/booking/dao/BookingRepository.java @@ -1,37 +1,38 @@ package com.beat.domain.booking.dao; -import com.beat.domain.booking.domain.Booking; +import java.util.List; +import java.util.Optional; + import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import java.util.List; -import java.util.Optional; +import com.beat.domain.booking.domain.Booking; public interface BookingRepository extends JpaRepository { - @Query("SELECT b FROM Booking b " + - "JOIN b.schedule s " + - "JOIN s.performance p " + - "WHERE b.bookerName = :bookerName " + - "AND b.bookerPhoneNumber = :bookerPhoneNumber " + - "AND b.password = :password " + - "AND b.birthDate = :birthDate") - Optional> findByBookerNameAndBookerPhoneNumberAndPasswordAndBirthDate( - @Param("bookerName") String bookerName, - @Param("bookerPhoneNumber") String bookerPhoneNumber, - @Param("password") String password, - @Param("birthDate") String birthDate - ); + @Query("SELECT b FROM Booking b " + + "JOIN b.schedule s " + + "JOIN s.performance p " + + "WHERE b.bookerName = :bookerName " + + "AND b.bookerPhoneNumber = :bookerPhoneNumber " + + "AND b.password = :password " + + "AND b.birthDate = :birthDate") + Optional> findByBookerNameAndBookerPhoneNumberAndPasswordAndBirthDate( + @Param("bookerName") String bookerName, + @Param("bookerPhoneNumber") String bookerPhoneNumber, + @Param("password") String password, + @Param("birthDate") String birthDate + ); - Optional findFirstByBookerNameAndBookerPhoneNumberAndBirthDateAndPassword( - String bookerName, - String bookerPhoneNumber, - String birthDate, - String password - ); + Optional findFirstByBookerNameAndBookerPhoneNumberAndBirthDateAndPassword( + String bookerName, + String bookerPhoneNumber, + String birthDate, + String password + ); - List findByUsersId(Long userId); + List findByUsersId(Long userId); - @Query("SELECT COUNT(b) > 0 FROM Booking b WHERE b.schedule.id IN :scheduleIds") - boolean existsByScheduleIdIn(@Param("scheduleIds") List scheduleIds); + @Query("SELECT COUNT(b) > 0 FROM Booking b WHERE b.schedule.id IN :scheduleIds AND b.bookingStatus != 'BOOKING_CANCELLED'") + boolean existsByScheduleIdIn(@Param("scheduleIds") List scheduleIds); } \ No newline at end of file