From 3b4b0ac1e3c208dcc3323ba413fc78be9ef9e775 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 8 May 2026 21:16:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=B6=E5=AD=97=E6=AE=B5=E6=9C=AA=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E5=AD=98=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/router/admin/versions.go | 44 +++++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) 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