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

Moderator pagination

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.