Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix #36

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,4 +26,15 @@ public interface DiscussionCommentsRepository extends JpaRepository<DiscussionCo
nativeQuery = true
)
Page<DiscussionComments> findByParentCommentId(Long parentCommentId, Pageable pageable);
}

void deleteAllByParentCommentId(DiscussionComments id);

List<DiscussionComments> findAllByDiscussionId(Long discussionId);

@Modifying
@Query("DELETE FROM DiscussionComments dc WHERE dc.parentCommentId.id IN :parentCommentIds")
void deleteAllByParentCommentIds(@Param("parentCommentIds") List<Long> parentCommentIds);

void deleteByDiscussionId(Long discussionId);

}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public interface SubCommentService {
DiscussionCommentsDto updateSubDiscussionComments(long id, DiscussionCommentsDto commentsDto, User user);

DiscussionCommentsDto deleteSubDiscussionComments(long id, User user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ private Long getUserId(User user) {
AuthUserResponse userData = userService.findByUsername(user.getUsername());
return userData.getId();
}
}
}