mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Add comment update functionality with UI integration
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user