Skip to content

Commit

Permalink
[#211] fix(BookingRepository): 예매자 존재 여부 확인 로직 변경 (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyerinhwang-sailin authored Sep 30, 2024
1 parent 7074729 commit 099dfcb
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions src/main/java/com/beat/domain/booking/dao/BookingRepository.java
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);
}

0 comments on commit 099dfcb

Please sign in to comment.