Ignore:
Timestamp:
10/07/21 20:07:41 (3 years ago)
Author:
KostaFortumanov <kfortumanov@…>
Branches:
master
Children:
0c37625
Parents:
0f4f552
Message:

post pagination

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/charitable/services/DonationPostService.java

    r0f4f552 r276a8b6  
    5454    }
    5555
    56     public Page<DonationPost> findPaginated(int pageNo, int pageSize, String sort) {
    57         Pageable pageable = PageRequest.of(pageNo - 1, pageSize, Sort.by(sort));
    58         return donationPostRepository.findAll(pageable);
     56    public Page<DonationPost> findPaginated(int pageNo, int pageSize, String sort, String order) {
     57        Sort s = Sort.by(sort);
     58        s = order.equals("asc") ? s.ascending() : s.descending();
     59        Pageable pageable = PageRequest.of(pageNo - 1, pageSize, s);
     60        return donationPostRepository.findAllByApproved(pageable, true);
    5961    }
    6062}
Note: See TracChangeset for help on using the changeset viewer.