DishRepository.java
775 bytes
| 1 | package com.tasteprint.catalog; |
|---|---|
| 2 | |
| 3 | import java.util.List; |
| 4 | |
| 5 | import org.springframework.data.domain.Pageable; |
| 6 | import org.springframework.data.jpa.repository.JpaRepository; |
| 7 | import org.springframework.data.jpa.repository.Query; |
| 8 | import org.springframework.data.repository.query.Param; |
| 9 | |
| 10 | interface DishRepository extends JpaRepository<Dish, String> { |
| 11 | |
| 12 | List<Dish> findByDestinationCodeOrderByDisplayOrderAsc(String destinationCode); |
| 13 | |
| 14 | @Query(""" |
| 15 | select d from Dish d |
| 16 | where lower(d.name) like lower(concat('%', :query, '%')) |
| 17 | or lower(coalesce(d.localName, '')) like lower(concat('%', :query, '%')) |
| 18 | order by d.importance desc, d.name asc |
| 19 | """) |
| 20 | List<Dish> search(@Param("query") String query, Pageable pageable); |
| 21 | } |
| 22 | |