Add comment update functionality with UI integration

This commit is contained in:
2025-06-20 13:49:36 +08:00
parent 9e0e83ecd9
commit 46186e95df
5 changed files with 151 additions and 4 deletions

View File

@@ -70,3 +70,16 @@ func GetCommentByID(commentID uint) (*model.Comment, error) {
}
return &comment, nil
}
func UpdateCommentContent(commentID uint, content string) (*model.Comment, error) {
var comment model.Comment
if err := db.First(&comment, commentID).Error; err != nil {
return nil, err
}
comment.Content = content
if err := db.Save(&comment).Error; err != nil {
return nil, err
}
db.Preload("User").First(&comment, commentID)
return &comment, nil
}