Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] #215 - 예매자 존재 여부 확인 로직 변경 #216

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Loading