diff --git a/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/comment/repository/CommentRepository.java b/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/comment/repository/CommentRepository.java index e6a76bc..4319943 100644 --- a/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/comment/repository/CommentRepository.java +++ b/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/comment/repository/CommentRepository.java @@ -37,4 +37,6 @@ default Comment findCommentByIdOrThrow(Long commentId) { return findCommentById(commentId) .orElseThrow(() -> new NotFoundException(ErrorStatus.NOT_FOUND_COMMENT.getMessage())); } + + void deleteCommentsByMemberId(Long memberId); } \ No newline at end of file diff --git a/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/content/service/ContentCommandService.java b/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/content/service/ContentCommandService.java index 0a1bc0f..8f102e4 100644 --- a/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/content/service/ContentCommandService.java +++ b/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/content/service/ContentCommandService.java @@ -50,11 +50,9 @@ public void deleteContent(Long memberId, Long contentId) { List comments = commentRepository.findCommentsByContentId(contentId); for(Comment comment : comments) { notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentLiked",comment.getId()); -// notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentGhost",comment.getId()); //변경 후 다시 바꾸기 + //notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentGhost",comment.getId()); //변경 후 다시 바꾸기 notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentGhost",contentId); notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("comment", comment.getId()); - commentLikedRepository.deleteByComment(comment); - commentRepository.deleteById(comment.getId()); } notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("contentLiked",contentId); notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("contentGhost",contentId); diff --git a/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/member/service/MemberCommandService.java b/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/member/service/MemberCommandService.java index b1c8ca4..40ca111 100644 --- a/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/member/service/MemberCommandService.java +++ b/DontBeServer/src/main/java/com/dontbe/www/DontBeServer/api/member/service/MemberCommandService.java @@ -40,7 +40,7 @@ public void testWithdrawalMember(Long memberId){ List ghostList1 = ghostRepository.findByGhostTargetMember(member); List ghostList2 = ghostRepository.findByGhostTriggerMember(member); - //게시글들 안에서 각 게시글에 대한 답글들의 좋아요 노티, 투명도 노티, 답글 노티, 답글 삭제 + 게시글 좋아요 삭제, 게시글 투명도 삭제, 게시글 삭제(소프트 딜리트 X) + //게시글들 안에서 각 게시글에 대한 답글들의 좋아요 노티, 투명도 노티, 답글 노티, 게시글 투명도 삭제, 게시글 삭제(소프트 딜리트 X) for(Content content : contentList) { Long contentId = content.getId(); List comments = commentRepository.findCommentsByContentId(contentId); @@ -49,8 +49,6 @@ public void testWithdrawalMember(Long memberId){ // notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentGhost",comment.getId()); //변경 후 다시 바꾸기 notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentGhost",contentId); notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("comment", comment.getId()); - commentLikedRepository.deleteByComment(comment); - commentRepository.deleteById(comment.getId()); } notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("contentLiked",contentId); notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("contentGhost",contentId); @@ -69,7 +67,10 @@ public void testWithdrawalMember(Long memberId){ //이대로 진행할 경우 어떤 유저는 평생 default값이 -1일 수도ㅜㅜ ghostRepository.deleteAll(ghostList1); ghostRepository.deleteAll(ghostList2); -// contentRepository.deleteAll(contentList); + + //탈퇴하는 유저가 작성한 답글 삭제 + commentRepository.deleteCommentsByMemberId(memberId); + memberRepository.delete(member); }