fix: 修复版本更新时字段未正确保存的问题
This commit is contained in:
@@ -356,24 +356,54 @@ func handleUpdateVersionGlobal(c *gin.Context) {
|
|||||||
if req.Version != "" {
|
if req.Version != "" {
|
||||||
version.Version = req.Version
|
version.Version = req.Version
|
||||||
}
|
}
|
||||||
version.ForceUpdate = req.ForceUpdate
|
|
||||||
if req.UpdateStrategy != "" {
|
if req.UpdateStrategy != "" {
|
||||||
version.UpdateStrategy = req.UpdateStrategy
|
version.UpdateStrategy = req.UpdateStrategy
|
||||||
}
|
}
|
||||||
if req.UpdateMethod != "" {
|
if req.UpdateMethod != "" {
|
||||||
version.UpdateMethod = req.UpdateMethod
|
version.UpdateMethod = req.UpdateMethod
|
||||||
}
|
}
|
||||||
|
if req.MinVersion != "" {
|
||||||
version.MinVersion = req.MinVersion
|
version.MinVersion = req.MinVersion
|
||||||
|
}
|
||||||
|
if req.Description != "" {
|
||||||
version.Description = req.Description
|
version.Description = req.Description
|
||||||
|
}
|
||||||
|
if req.Changelog != "" {
|
||||||
version.Changelog = req.Changelog
|
version.Changelog = req.Changelog
|
||||||
|
}
|
||||||
if req.Status != "" {
|
if req.Status != "" {
|
||||||
version.Status = req.Status
|
version.Status = req.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := database.DB.Save(&version).Error; err != nil {
|
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, "更新版本失败")
|
response.Error(c, 500, "更新版本失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
userIDPtr := &userID
|
userIDPtr := &userID
|
||||||
versionIDPtr := &version.ID
|
versionIDPtr := &version.ID
|
||||||
|
|||||||
Reference in New Issue
Block a user