package ba.unsa.etf.si.bbqms.repository;

import ba.unsa.etf.si.bbqms.domain.Ticket;

import java.time.Instant;
import java.util.Collection;
import java.util.List;
import java.util.Optional;

public interface TicketRepository extends BaseRepository<Ticket, Long> {
    List<Ticket> findByDeviceToken(String deviceToken);

    List<Ticket> findByBranch_Id(long branchId);

    List<Ticket> findByService_Id(long serviceId);

    List<Ticket> findByService_IdInAndBranch_Id(Collection<Long> serviceIds, long branchId);

    List<Ticket> findByService_IdInAndBranch_IdAndDeletedOrderByCreatedAtAsc(
            Collection<Long> serviceIds, long branchId, boolean deleted);

    List<Ticket> findByService_IdInAndBranch_IdAndTellerStationIsNullAndDeletedFalseOrderByCreatedAtAsc(
            Collection<Long> serviceIds, long branchId);

    Optional<Ticket> findByTellerStation_IdAndDeletedFalse(long stationId);

    List<Ticket> findByTellerStation_IdAndDeletedTrueAndCreatedAtLessThanOrderByCreatedAtDesc(
            long stationId, Instant createdAt);

    List<Ticket> findByTellerStationIsNullOrderByCreatedAtAsc();
}
