package de.votian.services.repository;

import de.votian.services.entity.Tour;
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;

public interface TourRepository extends JpaRepository<Tour, Long> {

    List<Tour> findByJobIdOrderBySort(Long jobId);

    List<Tour> findByJobIdInOrderByJobIdAscSortAsc(List<Long> jobIds);

    Optional<Tour> findByJobIdAndSort(Long jobId, Integer sort);

    @Query("SELECT t FROM Tour t WHERE t.commissionNo = :commNo AND t.sort = 1")
    List<Tour> findByCommissionNo(@Param("commNo") String commNo);
}
