From 064881b8518ad74685cb7804f041f1d70cb5787f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=A0=95=EB=AF=BC?= Date: Mon, 12 Aug 2024 09:49:15 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20qna=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edufocus/qna/controller/QnaController.java | 10 ++++------ .../com/edufocus/edufocus/qna/service/QnaService.java | 2 +- .../edufocus/edufocus/qna/service/QnaServiceImpl.java | 9 +++------ 3 files changed, 8 insertions(+), 13 deletions(-) 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 {