package com.example.computers.repository;

import com.example.computers.entity.Computer;
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 ComputerRepository extends JpaRepository<Computer, Long> {
    @Query("SELECT c FROM Computer c WHERE " +
            "LOWER(c.inventoryNumber) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
            "LOWER(c.model) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
            "LOWER(c.status) LIKE LOWER(CONCAT('%', :q, '%'))")
    List<Computer> search(@Param("q") String query);
}