mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 23:51:15 +00:00
Fix comment deleting
This commit is contained in:
@@ -183,6 +183,10 @@ func DeleteCommentByID(commentID uint) error {
|
|||||||
if err := tx.Model(&model.Resource{}).Where("id = ?", comment.RefID).Update("comments", gorm.Expr("comments - 1")).Error; err != nil {
|
if err := tx.Model(&model.Resource{}).Where("id = ?", comment.RefID).Update("comments", gorm.Expr("comments - 1")).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
} else if comment.Type == model.CommentTypeReply {
|
||||||
|
if err := tx.Model(&model.Comment{}).Where("id = ?", comment.RefID).Update("reply_count", gorm.Expr("reply_count - 1")).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := tx.
|
if err := tx.
|
||||||
Where("type = ? and ref_id = ?", model.ActivityTypeNewComment, commentID).
|
Where("type = ? and ref_id = ?", model.ActivityTypeNewComment, commentID).
|
||||||
|
|||||||
Reference in New Issue
Block a user