package com.example.computers.repository;

import com.example.computers.entity.Location;
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 LocationRepository extends JpaRepository<Location, Long> {
    @Query("SELECT l FROM Location l WHERE " +
            "LOWER(l.building) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
            "LOWER(l.room) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
            "LOWER(l.responsiblePerson) LIKE LOWER(CONCAT('%', :q, '%'))")
    List<Location> search(@Param("q") String query);
}