diff --git a/backend/internal/router/admin/versions.go b/backend/internal/router/admin/versions.go index 56081c1..c4d63c9 100644 --- a/backend/internal/router/admin/versions.go +++ b/backend/internal/router/admin/versions.go @@ -356,23 +356,53 @@ func handleUpdateVersionGlobal(c *gin.Context) { if req.Version != "" { version.Version = req.Version } - version.ForceUpdate = req.ForceUpdate if req.UpdateStrategy != "" { version.UpdateStrategy = req.UpdateStrategy } if req.UpdateMethod != "" { version.UpdateMethod = req.UpdateMethod } - version.MinVersion = req.MinVersion - version.Description = req.Description - version.Changelog = req.Changelog + if req.MinVersion != "" { + version.MinVersion = req.MinVersion + } + if req.Description != "" { + version.Description = req.Description + } + if req.Changelog != "" { + version.Changelog = req.Changelog + } if req.Status != "" { version.Status = req.Status } - if err := database.DB.Save(&version).Error; err != nil { - response.Error(c, 500, "更新版本失败") - return + updates := map[string]interface{}{} + if req.Version != "" { + updates["version"] = req.Version + } + if req.UpdateStrategy != "" { + updates["update_strategy"] = req.UpdateStrategy + } + if req.UpdateMethod != "" { + updates["update_method"] = req.UpdateMethod + } + if req.MinVersion != "" { + updates["min_version"] = req.MinVersion + } + if req.Description != "" { + updates["description"] = req.Description + } + if req.Changelog != "" { + updates["changelog"] = req.Changelog + } + if req.Status != "" { + updates["status"] = req.Status + } + + if len(updates) > 0 { + if err := database.DB.Model(&version).Updates(updates).Error; err != nil { + response.Error(c, 500, "更新版本失败") + return + } } userIDPtr := &userID