페이징처리가 없는 전체 읽어오기
controller
게시글 페이징처리 하기 시작
service
ScoreMongoOperations
몽고디비에서 조회해온다
엄정화 성적등록 후 -> sysout
controller
김혜선 성적등록 후 -> sysout
페이징처리가 있는 전체 읽어오기
ScoreMongoOperations
public List<Score> listScore(int currentShowPageNo, int sizePerPage) {
List<Score> list = null;
// >>> 페이징처리가 있는 전체 읽어오기 시작 <<<
currentShowPageNo = currentShowPageNo >= 1 ? (currentShowPageNo - 1) : 0;
/*
// 페이징처리 => 1페이지 10개 데이타 조회
Pageable pageable = new PageRequest(0, 10); // (page, size) 에서 page는 보고자하는 페이지번호에서 1을 뺀값으로 해야 한다.
Query query = new Query();
query.with(pageable);
list = mongo.find(query, Score.class);
*/
//Pageable pageable = PageRequest.of(currentShowPageNo, sizePerPage, Sort.by(Sort.Direction.DESC, "tot"));
Pageable pageable = PageRequest.of(currentShowPageNo, sizePerPage, Sort.by(Sort.Direction.ASC, "hakbeon"));
Query query = new Query();
query.with(pageable);
list = mongo.find(query, Score.class);
// >>> 페이징처리가 있는 전체 읽어오기 끝 <<<
return list;
}
학번 오름차순 정렬되어 1페이지 결과물이 나온다.
defaultValue를 "2" 로 바꿔주면
2페이지 결과물이 나온다.