File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
back/src/main/java/com/back/domain/post Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 22
33import com .back .domain .post .dto .PostRequest ;
44import com .back .domain .post .dto .PostResponse ;
5+ import com .back .domain .post .dto .PostSearchCondition ;
56import com .back .domain .post .service .PostService ;
67import com .back .global .common .ApiResponse ;
78import com .back .global .common .PageResponse ;
@@ -36,8 +37,9 @@ public ApiResponse<PostResponse> createPost(
3637
3738 // 게시글 목록 조회
3839 @ GetMapping
39- public ApiResponse <PageResponse <PostResponse >> getPosts (Pageable pageable ) {
40- Page <PostResponse > responses = postService .getPosts (pageable );
40+ public ApiResponse <PageResponse <PostResponse >> getPosts (
41+ @ ModelAttribute PostSearchCondition condition , Pageable pageable ) {
42+ Page <PostResponse > responses = postService .getPosts (condition , pageable );
4143 return ApiResponse .success (PageResponse .of (responses ), "성공적으로 조회되었습니다." , HttpStatus .OK );
4244 }
4345
Original file line number Diff line number Diff line change 22
33import com .back .domain .post .dto .PostRequest ;
44import com .back .domain .post .dto .PostResponse ;
5+ import com .back .domain .post .dto .PostSearchCondition ;
56import com .back .domain .post .entity .Post ;
67import com .back .domain .post .mapper .PostMapper ;
78import com .back .domain .post .repository .PostRepository ;
@@ -48,8 +49,8 @@ public PostResponse getPost(Long postId) {
4849 .orElseThrow (() -> new ApiException (ErrorCode .POST_NOT_FOUND ));
4950 }
5051
51- public Page <PostResponse > getPosts (Pageable pageable ) {
52- return postRepository .findAll ( pageable )
52+ public Page <PostResponse > getPosts (PostSearchCondition condition , Pageable pageable ) {
53+ return postRepository .searchPosts ( condition , pageable )
5354 .map (PostMapper ::toResponse );
5455 }
5556
You can’t perform that action at this time.
0 commit comments