feat : 게시판 조회 최신순 조회로 변경

This commit is contained in:
yulmam 2024-08-08 09:47:06 +09:00
parent 208bd69d5b
commit 918906de60
2 changed files with 3 additions and 2 deletions

View File

@ -38,7 +38,7 @@ public class BoardController {
List<ResponseBoardSummaryDto> 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);
}

View File

@ -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<ResponseBoardSummaryDto> 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<Board> boards = boardRepository.findByLectureIdAndCategory(lectureId, category, pageable).getContent();