29 lines
1.4 KiB
Java
29 lines
1.4 KiB
Java
package org.hso.ecommerce.repos.booking;
|
|
|
|
import java.util.List;
|
|
|
|
import org.hso.ecommerce.entities.booking.Booking;
|
|
import org.springframework.data.jpa.repository.JpaRepository;
|
|
import org.springframework.data.jpa.repository.Query;
|
|
import org.springframework.stereotype.Repository;
|
|
|
|
@Repository
|
|
public interface BookingRepository extends JpaRepository<Booking, Long> {
|
|
|
|
@Query("SELECT b FROM Booking b ORDER BY b.id DESC")
|
|
List<Booking> allBookingsReverseChronologically();
|
|
|
|
@Query("SELECT b FROM Booking b LEFT JOIN b.source s LEFT JOIN b.destination d WHERE s.isMainAccount = 1 OR d.isMainAccount = 1 ORDER BY b.id DESC")
|
|
List<Booking> mainBookingsReverseChronologically();
|
|
|
|
@Query("SELECT b FROM Booking b LEFT JOIN b.source s LEFT JOIN b.destination d WHERE s.isVATAccount = 1 OR d.isVATAccount = 1 ORDER BY b.id DESC")
|
|
List<Booking> vatBookingsReverseChronologically();
|
|
|
|
@Query("SELECT b FROM Booking b LEFT JOIN b.source s LEFT JOIN b.destination d WHERE s.userAccount.id = :customerId OR d.userAccount.id = :customerId ORDER BY b.id DESC")
|
|
List<Booking> customerBookingsReverseChronologically(long customerId);
|
|
|
|
@Query("SELECT b FROM Booking b LEFT JOIN b.source s LEFT JOIN b.destination d WHERE s.supplierAccount.id = :supplierId OR d.supplierAccount.id = :supplierId ORDER BY b.id DESC")
|
|
List<Booking> supplierBookingsReverseChronologically(long supplierId);
|
|
|
|
}
|