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();