package com.mvrent.carrental.repository;

import com.mvrent.carrental.model.MaintenanceRecord;
import com.mvrent.carrental.model.MaintenanceStatus;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Collection;
import java.util.List;

public interface MaintenanceRepository extends JpaRepository<MaintenanceRecord, Long> {

    List<MaintenanceRecord> findAllByOrderByServiceDateDescIdDesc();

    List<MaintenanceRecord> findByCarIdOrderByServiceDateDescIdDesc(Long carId);

    boolean existsByCarIdAndStatusIn(Long carId, Collection<MaintenanceStatus> statuses);

    long countByStatusIn(Collection<MaintenanceStatus> statuses);
}
