fix: 添加调试日志排查版本更新不生效问题
This commit is contained in:
@@ -323,10 +323,13 @@ func handleUpdateVersionGlobal(c *gin.Context) {
|
|||||||
|
|
||||||
var req UpdateVersionRequest
|
var req UpdateVersionRequest
|
||||||
if err := c.ShouldBindJSON(&req); err != nil {
|
if err := c.ShouldBindJSON(&req); err != nil {
|
||||||
|
log.Printf("[ERROR] ShouldBindJSON failed: %v\n", err)
|
||||||
response.Error(c, 400, "参数错误")
|
response.Error(c, 400, "参数错误")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] UpdateVersionRequest parsed: %+v\n", req)
|
||||||
|
|
||||||
var userApps []model.Application
|
var userApps []model.Application
|
||||||
if err := database.DB.Where("user_id = ?", userID).Find(&userApps).Error; err != nil {
|
if err := database.DB.Where("user_id = ?", userID).Find(&userApps).Error; err != nil {
|
||||||
response.Error(c, 500, "获取应用列表失败")
|
response.Error(c, 500, "获取应用列表失败")
|
||||||
@@ -350,30 +353,10 @@ func handleUpdateVersionGlobal(c *gin.Context) {
|
|||||||
response.Error(c, 400, "该版本号已存在")
|
response.Error(c, 400, "该版本号已存在")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
version.Version = req.Version
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Version != "" {
|
log.Printf("[DEBUG] handleUpdateVersionGlobal versionID=%s, req: version=%s, update_strategy=%s, update_method=%s, description=%s\n",
|
||||||
version.Version = req.Version
|
versionID, req.Version, req.UpdateStrategy, req.UpdateMethod, req.Description)
|
||||||
}
|
|
||||||
if req.UpdateStrategy != "" {
|
|
||||||
version.UpdateStrategy = req.UpdateStrategy
|
|
||||||
}
|
|
||||||
if req.UpdateMethod != "" {
|
|
||||||
version.UpdateMethod = req.UpdateMethod
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
updates := map[string]interface{}{}
|
updates := map[string]interface{}{}
|
||||||
if req.Version != "" {
|
if req.Version != "" {
|
||||||
@@ -398,11 +381,24 @@ func handleUpdateVersionGlobal(c *gin.Context) {
|
|||||||
updates["status"] = req.Status
|
updates["status"] = req.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(updates) > 0 {
|
log.Printf("[DEBUG] Updates map: %+v\n", updates)
|
||||||
if err := database.DB.Model(&version).Updates(updates).Error; err != nil {
|
|
||||||
|
if len(updates) == 0 {
|
||||||
|
response.Success(c, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result := database.DB.Model(&model.Version{}).Where("id = ?", versionID).Updates(updates)
|
||||||
|
if result.Error != nil {
|
||||||
|
log.Printf("[ERROR] Updates failed: %v\n", result.Error)
|
||||||
response.Error(c, 500, "更新版本失败")
|
response.Error(c, 500, "更新版本失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] Updates rows affected: %d\n", result.RowsAffected)
|
||||||
|
if result.RowsAffected == 0 {
|
||||||
|
response.Error(c, 500, "更新未生效,请重试")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userIDPtr := &userID
|
userIDPtr := &userID
|
||||||
|
|||||||
@@ -180,13 +180,16 @@ async function handleSubmit() {
|
|||||||
entry_file: formData.value.entry_file,
|
entry_file: formData.value.entry_file,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('[DEBUG] handleSubmit payload:', JSON.stringify(payload))
|
||||||
|
|
||||||
if (uploadedData.value) {
|
if (uploadedData.value) {
|
||||||
payload.file_path = uploadedData.value.file_path
|
payload.file_path = uploadedData.value.file_path
|
||||||
payload.file_size = uploadedData.value.file_size
|
payload.file_size = uploadedData.value.file_size
|
||||||
payload.file_hash = uploadedData.value.file_hash
|
payload.file_hash = uploadedData.value.file_hash
|
||||||
}
|
}
|
||||||
|
|
||||||
await api.put(`/dev/versions/${versionId.value}`, payload)
|
const response = await api.put(`/dev/versions/${versionId.value}`, payload)
|
||||||
|
console.log('[DEBUG] handleSubmit response:', response)
|
||||||
toast.success(t('admin.versions.createForm.updateSuccess'))
|
toast.success(t('admin.versions.createForm.updateSuccess'))
|
||||||
router.push('/admin/versions')
|
router.push('/admin/versions')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user