Skip to content

Commit

Permalink
[MODIFY] commentCount delete update
Browse files Browse the repository at this point in the history
- commentCount delete update
  • Loading branch information
himodu committed May 20, 2024
1 parent 03e178e commit 0486533
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 0486533

Please sign in to comment.