Skip to content

Commit

Permalink
fix:게시판 수정 후 저장 누락 확인. 좋아요와 업데이트, 삭제 시 저장
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy0006 committed Jan 21, 2024
1 parent a1ee4f7 commit 845d568
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/poolc/api/post/service/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,37 @@ public void updatePost(Member member, Long postId, PostUpdateValues values) {
Post post = findPostById(member, postId);
checkWriter(member, post);
post.updatePost(post.getPostType(), values);
postRepository.save(post);
}

public void likePost(Member member, Long postId) {
Post post = findPostById(member, postId);
checkNotWriter(member, post);
post.addLikeCount();
badgeConditionService.like(post.getMember());
postRepository.save(post);
}

public void dislikePost(Member member, Long postId) {
Post post = findPostById(member, postId);
checkNotWriter(member, post);
post.deductLikeCount();
badgeConditionService.dislike(post.getMember());
postRepository.save(post);
}

public void scrapPost(Member member, Long postId) {
Post post = findPostById(member, postId);
checkNotWriter(member, post);
post.addScrapCount();
postRepository.save(post);
}

public void unscrapPost(Member member, Long postId) {
Post post = findPostById(member, postId);
checkNotWriter(member, post);
post.deductScrapCount();
postRepository.save(post);
}

public void deletePost(Member member, Long postId) {
Expand All @@ -113,6 +118,7 @@ public void deletePost(Member member, Long postId) {
post.setIsDeleted();
}
BoardType.removePostCount(post.getBoardType());
postRepository.save(post);
}

public List<PostResponse> searchPost(Member member, String keyword, int page) {
Expand Down

0 comments on commit 845d568

Please sign in to comment.