Ignore:
Timestamp:
10/07/21 20:22:23 (3 years ago)
Author:
NikolaCenevski <cenevskinikola@…>
Branches:
master
Children:
ee0e297
Parents:
276a8b6
Message:

Moderator pagination

Location:
src/main/java/it/finki/charitable/services
Files:
2 edited

Legend:

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

    r276a8b6 r0c37625  
    5454    }
    5555
    56     public Page<DonationPost> findPaginated(int pageNo, int pageSize, String sort, String order) {
     56    public Page<DonationPost> findPaginated(int pageNo, int pageSize, String sort, String order, boolean approved) {
    5757        Sort s = Sort.by(sort);
    5858        s = order.equals("asc") ? s.ascending() : s.descending();
    5959        Pageable pageable = PageRequest.of(pageNo - 1, pageSize, s);
    60         return donationPostRepository.findAllByApproved(pageable, true);
     60        return donationPostRepository.findAllByApproved(pageable, approved);
    6161    }
    6262}
  • src/main/java/it/finki/charitable/services/ReportPostService.java

    r276a8b6 r0c37625  
    55import it.finki.charitable.entities.ReportPost;
    66import it.finki.charitable.repository.ReportPostRepository;
     7import org.springframework.data.domain.Page;
     8import org.springframework.data.domain.PageRequest;
     9import org.springframework.data.domain.Pageable;
     10import org.springframework.data.domain.Sort;
    711import org.springframework.stereotype.Service;
    812
     
    1822    }
    1923
    20     public List<ReportPost> findAll() {
    21         return reportPostRepository.findAll();
     24    public Page<ReportPost> findAll(int pageNo, int pageSize, String sort, String order) {
     25        Sort s = Sort.by(sort);
     26        s = order.equals("asc") ? s.ascending() : s.descending();
     27        Pageable pageable = PageRequest.of(pageNo - 1, pageSize, s);
     28        return reportPostRepository.findAll(pageable);
    2229    }
    2330
Note: See TracChangeset for help on using the changeset viewer.