package de.thpeetz.kontor.tysc.repository;

import java.util.List;

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

public interface PlayerRepository extends JpaRepository<Player, String> {

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

    Player findByFirstNameAndLastName(String firstName, String lastName);
}
