Skip to content

Commit

Permalink
Merge pull request #171 from pknu-wap/fix/찐찐찐막
Browse files Browse the repository at this point in the history
Fix/찐찐찐막
  • Loading branch information
Due-IT authored Nov 29, 2023
2 parents c95cb54 + 83768f7 commit cd4d400
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ public ResponseEntity<PostPreviewDtos> searchPost(@RequestParam(defaultValue = "
}

@GetMapping("/search/category")
public ResponseEntity<PostPreviewDtos> searchContentsByCategory(@RequestParam Long categoryId) {
public ResponseEntity<PostPreviewDtos> searchContentsByCategory(@RequestParam Long categoryId, @RequestParam int page) {
//content 내용을 포함한 게시글의 리스트를 생성한다.
PostPreviewDtos postPreviewDtos = postService.searchPostsByCategory(categoryId);
PostPreviewDtos postPreviewDtos = postService.searchPostsByCategory(categoryId, page);

return new ResponseEntity<>(postPreviewDtos, HttpStatus.OK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public interface PostRepository extends JpaRepository<Post,Long> {

List<Post> findAllByTitleContaining(String title);
List<Post> findAllByUser(User user);
List<Post> findAllByCategory(Category category);
List<Post> findAllByContentContaining(String contnt);
Page<Post> findPostsByCategory(Category category, Pageable pageable);
List<Post> findAllByContentContaining(String content);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,12 @@ public String clickLike(UserPrincipal userPrincipal, Long postId) {
}
}

public PostPreviewDtos searchPostsByCategory(Long categoryId) {
public PostPreviewDtos searchPostsByCategory(Long categoryId, int page) {
Category category = categoryRepository.findByCategoryId(categoryId);
List<Post> posts = postRepository.findAllByCategory(category);
PageRequest pageRequest = PageRequest.of(page, 8, Sort.by("id").descending());
Page<Post> posts = postRepository.findPostsByCategory(category, pageRequest);

return new PostPreviewDtos(posts, posts.size());
return new PostPreviewDtos(posts.getContent(), -1);
}

private void setPostHashtag(Post post, List<String> hashtagList) {
Expand Down
64 changes: 0 additions & 64 deletions server/src/main/resources/data.sql

This file was deleted.

0 comments on commit cd4d400

Please sign in to comment.