[Java Spring] Built-in page and sorting

package com.example.ec.repo;

import com.example.ec.domain.Difficulty;
import com.example.ec.domain.Region;
import com.example.ec.domain.Tour;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.*;


public interface TourRepository extends PagingAndSortingRepository<Tour, Integer> {

    // without paging
    // /tours/search/findByTourPackageCode?code=CC
    List<Tour> findByTourPackageCode(@Param("code") String codee);

    // with paging and sorting
    // /tours/search/findByTourPackageCode?code=CC&size=3&sort=title,asc
    Page<Tour> findByTourPackageCode(@Param("code") String code, Pageable pageable);
}

 

posted @ 2020-12-14 03:51  Zhentiw  阅读(56)  评论(0编辑  收藏  举报