diff --git a/backend/src/main/java/com/waa/project/repository/DiscussionCommentsRepository.java b/backend/src/main/java/com/waa/project/repository/DiscussionCommentsRepository.java index 7dcbc80..28d7946 100644 --- a/backend/src/main/java/com/waa/project/repository/DiscussionCommentsRepository.java +++ b/backend/src/main/java/com/waa/project/repository/DiscussionCommentsRepository.java @@ -4,9 +4,12 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.Optional; @Repository @@ -23,4 +26,15 @@ public interface DiscussionCommentsRepository extends JpaRepository findByParentCommentId(Long parentCommentId, Pageable pageable); -} + + void deleteAllByParentCommentId(DiscussionComments id); + + List findAllByDiscussionId(Long discussionId); + + @Modifying + @Query("DELETE FROM DiscussionComments dc WHERE dc.parentCommentId.id IN :parentCommentIds") + void deleteAllByParentCommentIds(@Param("parentCommentIds") List parentCommentIds); + + void deleteByDiscussionId(Long discussionId); + +} \ No newline at end of file diff --git a/backend/src/main/java/com/waa/project/service/DiscussionCommentsService.java b/backend/src/main/java/com/waa/project/service/DiscussionCommentsService.java index a437a0c..6c36e0f 100644 --- a/backend/src/main/java/com/waa/project/service/DiscussionCommentsService.java +++ b/backend/src/main/java/com/waa/project/service/DiscussionCommentsService.java @@ -1,6 +1,7 @@ package com.waa.project.service; import com.waa.project.dto.DiscussionCommentsDto; +import com.waa.project.entity.Discussion; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.security.core.userdetails.User; @@ -16,4 +17,6 @@ public interface DiscussionCommentsService { DiscussionCommentsDto updateDiscussionComments(long id, DiscussionCommentsDto commentsDto, User user); DiscussionCommentsDto deleteDiscussionComments(long id, User user); -} + + void deleteAllCommentsByDiscussionId(Discussion discussion); +} \ No newline at end of file diff --git a/backend/src/main/java/com/waa/project/service/SubCommentService.java b/backend/src/main/java/com/waa/project/service/SubCommentService.java index 58aab85..ea0edd3 100644 --- a/backend/src/main/java/com/waa/project/service/SubCommentService.java +++ b/backend/src/main/java/com/waa/project/service/SubCommentService.java @@ -14,4 +14,4 @@ public interface SubCommentService { DiscussionCommentsDto updateSubDiscussionComments(long id, DiscussionCommentsDto commentsDto, User user); DiscussionCommentsDto deleteSubDiscussionComments(long id, User user); -} +} \ No newline at end of file diff --git a/backend/src/main/java/com/waa/project/service/impl/DiscussionCommentsServiceImpl.java b/backend/src/main/java/com/waa/project/service/impl/DiscussionCommentsServiceImpl.java index f55cd1b..faba2ab 100644 --- a/backend/src/main/java/com/waa/project/service/impl/DiscussionCommentsServiceImpl.java +++ b/backend/src/main/java/com/waa/project/service/impl/DiscussionCommentsServiceImpl.java @@ -108,4 +108,4 @@ private Long getUserId(User user) { AuthUserResponse userData = userService.findByUsername(user.getUsername()); return userData.getId(); } -} +} \ No newline at end of file