Skip to content

Commit

Permalink
Merge pull request #12 from LikeLion-KNU/HOTFIX
Browse files Browse the repository at this point in the history
[MODIFY] commentCount delete update
  • Loading branch information
himodu authored May 20, 2024
2 parents 94ddfe0 + 0486533 commit 7341f92
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ public Long postComment(int boothNum, String categori, CommentRequest commentReq
public void deleteComment(Long commentId, String userHash) {
Optional<CommentEntity> commentOp = commentRepository.findById(commentId);

CommentEntity comment;
BoothEntity booth;
if(commentOp.isEmpty()) {
throw new NoExistException("해당 댓글은 없습니다. (id 확인 요망)");
}else{
if(commentOp.get().getUser().getUserHash().equals(userHash)){
commentRepository.delete(commentOp.get());
comment = commentOp.get();
booth = comment.getBooth();
booth.setCommentCount(booth.getCommentCount()-1);
boothRepository.save(booth);
commentRepository.delete(comment);
}else{
throw new UserHashWrongException("userHash 값이 일치하지 않습니다.");
}
Expand Down

0 comments on commit 7341f92

Please sign in to comment.