@Test public void findCategoryByPageAndOrder() { Page<Category> pageAndOrder = categoryService.findCategoryByPageAndOrder(0, 5); List<Category> content = pageAndOrder.getContent(); for (Category category : content) { System.out.println(category.toString()); } }
@Override public Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber) { List<Sort.Order> orders = new ArrayList<>(); orders.add(new Sort.Order(Sort.Direction.DESC,"id")); PageRequest pageRequest = new PageRequest(starPage,itemNumber,new Sort(orders)); return categoryRepository.findAll(pageRequest); }
CategoryServiceImpl implements CategoryService { @Override public Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber) { List<Sort.Order> orders = new ArrayList<>(); orders.add(new Sort.Order(Sort.Direction.DESC,"id")); PageRequest pageRequest = new PageRequest(starPage,itemNumber,new Sort(orders)); return categoryRepository.findAll(pageRequest); } }
CategoryServiceImpl implements CategoryService { @Override public Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber) { List<Sort.Order> orders = new ArrayList<>(); orders.add(new Sort.Order(Sort.Direction.DESC,"id")); PageRequest pageRequest = new PageRequest(starPage,itemNumber,new Sort(orders)); return categoryRepository.findAll(pageRequest); }  }
CategoryServiceImpl implements CategoryService { @Override public Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber) { List<Sort.Order> orders = new ArrayList<>(); orders.add(new Sort.Order(Sort.Direction.DESC,"id")); PageRequest pageRequest = new PageRequest(starPage,itemNumber,new Sort(orders)); return categoryRepository.findAll(pageRequest); }  @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void updateCategory(Category category); @Override Iterable<Category> findAll(); @Override Category findCategoryById(Long id); @Override Page<Category> findCategoryByPage(Integer starPage, Integer itemNumber); @Override Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber); }
CategoryServiceImpl implements CategoryService { @Override public Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber) { List<Sort.Order> orders = new ArrayList<>(); orders.add(new Sort.Order(Sort.Direction.DESC,"id")); PageRequest pageRequest = new PageRequest(starPage,itemNumber,new Sort(orders)); return categoryRepository.findAll(pageRequest); }  @Override void saveCategory(Category category); @Override void insertCategories(Iterable<Category> iterable); @Override void deleteCategoryById(Long id); @Override void updateCategory(Category category); @Override Iterable<Category> findAll(); @Override Category findCategoryById(Long id); @Override Page<Category> findCategoryByPage(Integer starPage, Integer itemNumber); @Override Page<Category> findCategoryByPageAndOrder(Integer starPage, Integer itemNumber);  }