package com.petshop.backend.repository;

import com.petshop.backend.entity.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface ServiceRepository extends JpaRepository<Service, Long> {

    @Query("SELECT s FROM Service s WHERE " +
           "LOWER(s.serviceName) LIKE LOWER(CONCAT('%', :q, '%')) OR " +
           "LOWER(s.serviceDesc) LIKE LOWER(CONCAT('%', :q, '%'))")
    Page<Service> searchServices(@Param("q") String query, Pageable pageable);
}
