package de.thpeetz.kontor.tysc.repository;

import java.util.List;

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

/**
 * The repository interface for managing teams.
 */
public interface TeamRepository extends JpaRepository<Team, String> {

    /**
     * Searches for teams based on a search term.
     *
     * @param searchTerm the search term to match against team names
     * @return a list of teams matching the search term
     */
    @Query("select t from Team t " +
            "where lower(t.name) like lower(concat('%', :searchTerm, '%')) ")
    List<Team> search(@Param("searchTerm") String searchTerm);

    Team findByName(String name);

    List<Team> findByNameIgnoreCase(String name);
}
