diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java b/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java index 3235b2c..dbc8c5b 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/controller/QnaController.java @@ -144,16 +144,14 @@ public class QnaController { } @GetMapping("/all/{id}") - public ResponseEntity> getAllQna(@PathVariable Long id) { + public ResponseEntity> getAllQna( + @PathVariable Long id, + @RequestParam(defaultValue = "0") int page) { try { - - - List qnaList = qnaService.getAllQnasByLecture(id, PAGE_SIZE); - + List qnaList = qnaService.getAllQnasByLecture(id, page, PAGE_SIZE); return new ResponseEntity<>(qnaList, HttpStatus.ACCEPTED); } catch (SQLException e) { return new ResponseEntity<>(HttpStatus.NOT_ACCEPTABLE); - } } } diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java index 877d4ef..c8468aa 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaService.java @@ -22,7 +22,7 @@ public interface QnaService { QnaResponseDto getQna(Long id, Long userId) throws SQLException; - List getAllQnasByLecture(Long lectureId, int pageNumber) throws SQLException; + List getAllQnasByLecture(Long lectureId, int page, int pageNumber) throws SQLException; QnaResponseDto createAnswer(Long id, QnaRequestDto qnaRequestDto) throws SQLException; diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java index bad6f09..b2b346a 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/service/QnaServiceImpl.java @@ -120,19 +120,16 @@ public class QnaServiceImpl implements QnaService { } @Override - public List getAllQnasByLecture(Long lectureId, int pageSize) { - - Pageable pageable = PageRequest.of(0, pageSize); - + public List getAllQnasByLecture(Long lectureId, int page, int pageSize) { + Pageable pageable = PageRequest.of(page, pageSize); Page qnaPage = qnaRepository.findByLectureId(lectureId, pageable); - return qnaPage.getContent().stream() .map(QnaResponseDto::toEntity) .collect(Collectors.toList()); - } + @Override public QnaResponseDto createAnswer(Long id, QnaRequestDto qnaRequestDto) throws SQLException {