|
20 | 20 | import com.wable.www.WableServer.external.fcm.service.FcmService;
|
21 | 21 | import com.wable.www.WableServer.external.s3.service.S3Service;
|
22 | 22 | import java.io.IOException;
|
| 23 | +import java.util.List; |
| 24 | + |
23 | 25 | import lombok.RequiredArgsConstructor;
|
24 | 26 | import org.springframework.stereotype.Service;
|
25 | 27 | import org.springframework.transaction.annotation.Transactional;
|
@@ -163,11 +165,27 @@ public void postCommentVer2(Long memberId, Long contentId, MultipartFile comment
|
163 | 165 | public void deleteComment(Long memberId, Long commentId) {
|
164 | 166 | deleteValidate(memberId, commentId);
|
165 | 167 |
|
166 |
| - notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentLiked",commentId); |
167 |
| - notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("comment",commentId); |
168 |
| - notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentGhost", commentId); |
169 |
| - |
170 | 168 | Comment deleteComment = commentRepository.findCommentByIdOrThrow(commentId);
|
| 169 | + if(deleteComment.getParentCommentId().equals(-1L)) { |
| 170 | + notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentLiked", commentId); |
| 171 | + notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("comment", commentId); |
| 172 | + notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentGhost", commentId); |
| 173 | + |
| 174 | + List<Comment> childComment = commentRepository.findChildComments(commentId); |
| 175 | + |
| 176 | + for (Comment comment : childComment) { |
| 177 | + Long childCommentId = comment.getId(); |
| 178 | + notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("childCommentLiked", childCommentId); |
| 179 | + notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("childComment", childCommentId); |
| 180 | + notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentGhost", childCommentId); |
| 181 | + comment.softDelete(); |
| 182 | + } |
| 183 | + } else { |
| 184 | + notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("childCommentLiked", commentId); |
| 185 | + notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("childComment", commentId); |
| 186 | + notificationRepository.deleteByNotificationTriggerTypeAndNotificationTriggerId("commentGhost", commentId); |
| 187 | + } |
| 188 | + |
171 | 189 | deleteComment.softDelete();
|
172 | 190 | }
|
173 | 191 |
|
|
0 commit comments