Skip to content

Commit

Permalink
bug fix (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
AungKyaw-Myint authored Jul 18, 2024
1 parent 07be05b commit 19f5227
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
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();
}
}
}

0 comments on commit 19f5227

Please sign in to comment.