优化一些逻辑。
This commit is contained in:
+4
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user