42Meet / reservation-service

http://42meet.kro.kr
0 stars 0 forks source link

Admin기능 API구현 #87

Open sebaek42 opened 3 years ago

sebaek42 commented 3 years ago

GET

GET

모두 pagenation을 고려해야함

[컨트롤러]

@GetMapping("/boards")
public String boardView(@PageableDefault Pageable pageable, Model model) {
  Page<Reservation> reservationList = reservationService.getReservationList(pageable);
  model.addAttribute("reservationList", reservationList);
  return "board";
}

[서비스]

public Page<Reservation> getReservationList(Pageable pageable) {
  int page = (pageable.getPageNumber() == 0) ? 0 : (pageable.getPageNumber() - 1);
  pageable = PageRequest.of(page, 10);
  return reservationRepository.findAll(pageable);
}

페이지네이션 참고 1: https://ivvve.github.io/2019/01/13/java/Spring/pagination_3/ 참고 2: https://bezkoder.com/react-spring-boot-pagination/