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/controller/ModeratorController.java

    r276a8b6 r0c37625  
    66import it.finki.charitable.services.ReasonService;
    77import it.finki.charitable.services.ReportPostService;
     8import org.springframework.data.domain.Page;
    89import org.springframework.security.core.context.SecurityContextHolder;
    910import org.springframework.stereotype.Controller;
     
    3334
    3435    @RequestMapping("moderator/approval")
    35     public String approval(Model model) {
    36         List<DonationPost> postList = donationPostService.findAllByApproved(false);
    37         if (postList.size() == 0) {
     36    public String approval(Model model,
     37                           @RequestParam int page,
     38                           @RequestParam String sort,
     39                           @RequestParam(required = false,defaultValue = "") String order) {
     40        Page<DonationPost> postList = donationPostService.findPaginated(page, 6, sort, order, false);
     41        if (postList.getSize() == 0) {
    3842            model.addAttribute("noPosts", true);
    3943            return "postApproval";
    4044        }
     45        model.addAttribute("totalPages", postList.getTotalPages());
    4146        model.addAttribute("postList", postList);
    4247        return "postApproval";
     
    9297
    9398    @RequestMapping("/moderator/report")
    94     public String reportedPosts(Model model) {
    95         List<ReportPost> postList = reportPostService.findAll();
    96         if (postList.size() == 0) {
     99    public String reportedPosts(Model model,
     100                                @RequestParam int page,
     101                                @RequestParam String sort,
     102                                @RequestParam(required = false,defaultValue = "") String order) {
     103        Page<ReportPost> postList = reportPostService.findAll(page, 6, sort, order);
     104        if (postList.getSize() == 0) {
    97105            model.addAttribute("noPosts", true);
    98106            return "reportedPosts";
Note: See TracChangeset for help on using the changeset viewer.