-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
7074729
commit 099dfcb
Showing
1 changed file
with
26 additions
and
25 deletions.
There are no files selected for viewing
51 changes: 26 additions & 25 deletions
51
src/main/java/com/beat/domain/booking/dao/BookingRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Booking, Long> { | ||
@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<List<Booking>> 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<List<Booking>> findByBookerNameAndBookerPhoneNumberAndPasswordAndBirthDate( | ||
@Param("bookerName") String bookerName, | ||
@Param("bookerPhoneNumber") String bookerPhoneNumber, | ||
@Param("password") String password, | ||
@Param("birthDate") String birthDate | ||
); | ||
|
||
Optional<Booking> findFirstByBookerNameAndBookerPhoneNumberAndBirthDateAndPassword( | ||
String bookerName, | ||
String bookerPhoneNumber, | ||
String birthDate, | ||
String password | ||
); | ||
Optional<Booking> findFirstByBookerNameAndBookerPhoneNumberAndBirthDateAndPassword( | ||
String bookerName, | ||
String bookerPhoneNumber, | ||
String birthDate, | ||
String password | ||
); | ||
|
||
List<Booking> findByUsersId(Long userId); | ||
List<Booking> findByUsersId(Long userId); | ||
|
||
@Query("SELECT COUNT(b) > 0 FROM Booking b WHERE b.schedule.id IN :scheduleIds") | ||
boolean existsByScheduleIdIn(@Param("scheduleIds") List<Long> 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<Long> scheduleIds); | ||
} |