package com.example.computers.repository;

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