package de.thpeetz.kontor.comics.repository;

import java.util.List;

import de.thpeetz.kontor.comics.data.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface IssueRepository extends JpaRepository<Issue, String> {
    @Query("select i from Issue i " +
            "where lower(i.issueNumber) like lower(concat('%', :searchTerm, '%')) ")
    List<Issue> search(@Param("searchTerm") String searchTerm);

    List<Issue> findByComic(Comic comic);

    Issue findByComicAndIssueNumber(Comic comic, String issueNumber);
}
