参考下面的例子

1
2
3
4
5
// extens CrudRepository 也没报错,可能也行
public interface UserRepository extends PagingAndSortingRepository<User, Long> {
@Query("select u from User u")
Page<User> getUserList(Pageable pageable);
}
1
2
3
4
5
6
7
8
9
10
11
@RestController
@RequestMapping("/user")
public class UserResource extends BaseResource{
@GetMapping(path = "/list")
public @ResponseBody
Page<User> list(@RequestParam("pageNum") Integer pageNum,
@RequestParam("pageSize") Integer pageSize) {
return userRepository.getUserList(PageRequest.of(pageNum, pageSize,
new Sort(Sort.Direction.DESC, "soldTotal", "soldCnt")));
}
}