package de.thpeetz.kontor.tysc.repository;

import java.util.List;

import de.thpeetz.kontor.tysc.data.FieldPosition;
import de.thpeetz.kontor.tysc.data.Sport;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface FieldPositionRepository extends JpaRepository<FieldPosition, String> {

    @Query("select p from FieldPosition p " +
            "where lower(p.name) like lower(concat('%', :searchTerm, '%')) ")
    List<FieldPosition> search(@Param("searchTerm") String searchTerm);

    List<FieldPosition> findBySport(Sport sport);

    FieldPosition findByShortName(String searchTerm);

    List<FieldPosition> findByShortNameIgnoreCase(String shortName);

    FieldPosition findByShortNameAndSport(String shortName, Sport sport);
}
