Skip to content

Commit a860983

Browse files
committed
fix(#42 search) : 검색 결과 기본 최신순으로 설정
1 parent 28853fa commit a860983

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/main/java/com/example/FixLog/controller/SearchController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.springframework.data.domain.Page;
99
import org.springframework.data.domain.PageRequest;
1010
import org.springframework.data.domain.Pageable;
11+
import org.springframework.data.domain.Sort;
1112
import org.springframework.web.bind.annotation.GetMapping;
1213
import org.springframework.web.bind.annotation.RequestMapping;
1314
import org.springframework.web.bind.annotation.RequestParam;
@@ -29,7 +30,7 @@ public Response<PageResponseDto<SearchPostDto>> search(
2930
@RequestParam(defaultValue = "0") int page,
3031
@RequestParam(defaultValue = "10") int size) {
3132

32-
Pageable pageable = PageRequest.of(page, size);
33+
Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "createdAt"));
3334
Page<SearchPostDto> result = searchService.searchPosts(keyword, tags, pageable);
3435

3536
PageResponseDto<SearchPostDto> responseDto = PageResponseDto.from(result, dto -> dto);

0 commit comments

Comments
 (0)