fixes+improvements
This commit is contained in:
@@ -182,4 +182,28 @@ public class CommentManager {
|
||||
return upvotes - downvotes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param comment
|
||||
*/
|
||||
public void delete(Comment comment) {
|
||||
for (Comment subcomment : commentRepository.findAll(qComment.parent.eq(comment.getId()))) {
|
||||
delete(subcomment);
|
||||
}
|
||||
|
||||
voteManager.deleteByTarget(comment.getId(), Types.comment);
|
||||
|
||||
commentRepository.delete(comment);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param target
|
||||
*/
|
||||
public void deleteByTarget(Long target) {
|
||||
for (Comment comment : commentRepository.findAll(qComment.target.eq(target))) {
|
||||
delete(comment);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -142,6 +142,16 @@ public class EntryManager {
|
||||
return entryRepository.save(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entry
|
||||
*/
|
||||
public void delete(Entry entry) {
|
||||
commentManager.deleteByTarget(entry.getId());
|
||||
voteManager.deleteByTarget(entry.getId(), Types.entry);
|
||||
entryRepository.delete(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entryId
|
||||
|
||||
@@ -52,6 +52,17 @@ public class VoteManager {
|
||||
voteRepository.delete(vote);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param vote
|
||||
*/
|
||||
public void deleteByTarget(Long target, Types targetType) {
|
||||
for (Vote vote : voteRepository
|
||||
.findAll(qVote.target.eq(target).and(qVote.targetType.eq(targetType)))) {
|
||||
delete(vote);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param target
|
||||
|
||||
Reference in New Issue
Block a user