package de.thpeetz.kontor.admin.repository;

import de.thpeetz.kontor.admin.data.Permission;
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;

public interface PermissionRepository extends JpaRepository<Permission, String> {

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

    @Query("select p from Permission p " +
            "where lower(p.name) like lower(:name) ")
    Permission findByName(@Param("name") String name);
}
