From 918906de60b4b058c1b7f64e577455d52097a4af Mon Sep 17 00:00:00 2001 From: yulmam <70622601+yulmam@users.noreply.github.com> Date: Thu, 8 Aug 2024 09:47:06 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20=EA=B2=8C=EC=8B=9C=ED=8C=90=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=B5=9C=EC=8B=A0=EC=88=9C=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edufocus/edufocus/board/controller/BoardController.java | 2 +- .../com/edufocus/edufocus/board/service/BoardServiceImpl.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/edufocus/edufocus/board/controller/BoardController.java b/backend/src/main/java/com/edufocus/edufocus/board/controller/BoardController.java index 309acb6..87e5410 100644 --- a/backend/src/main/java/com/edufocus/edufocus/board/controller/BoardController.java +++ b/backend/src/main/java/com/edufocus/edufocus/board/controller/BoardController.java @@ -38,7 +38,7 @@ public class BoardController { List boardSummaries = boardService.findBoards(pageNo, category, lectureId); if(boardSummaries.isEmpty()) - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + return new ResponseEntity<>(boardSummaries, HttpStatus.NO_CONTENT); return new ResponseEntity<>(boardSummaries, HttpStatus.OK); } diff --git a/backend/src/main/java/com/edufocus/edufocus/board/service/BoardServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/board/service/BoardServiceImpl.java index 3fc7250..a357de2 100644 --- a/backend/src/main/java/com/edufocus/edufocus/board/service/BoardServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/board/service/BoardServiceImpl.java @@ -12,6 +12,7 @@ import com.edufocus.edufocus.user.model.entity.vo.User; import com.edufocus.edufocus.user.model.repository.UserRepository; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -39,7 +40,7 @@ public class BoardServiceImpl implements BoardService { @Transactional public List findBoards(int pageNo, String category, long lectureId) { - Pageable pageable = PageRequest.of(pageNo, PAGE_SIZE); + Pageable pageable = PageRequest.of(pageNo, PAGE_SIZE, Sort.by("created_at").descending()); List boards = boardRepository.findByLectureIdAndCategory(lectureId, category, pageable).getContent();