优化一些逻辑。

This commit is contained in:
2026-08-06 17:45:06 +08:00
parent ea293f7866
commit ec1a19f469
5 changed files with 13 additions and 26 deletions
+4 -1
View File
@@ -264,7 +264,10 @@ func UpdatePost(c *gin.Context) {
})
tags = append(tags, tag)
}
database.DB.Model(&post).Association("Tags").Replace(tags)
if err := database.DB.Model(&post).Association("Tags").Replace(tags); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "更新文章标签失败"})
return
}
}
if err := database.DB.Model(&post).Updates(updates).Error; err != nil {