fix: 修复3个前端报错 — 实例分组编辑500/定时任务404/工作流null

1. instance_group.go: UpdateInstanceGroup 改用结构体输入,过滤系统字段,防止GORM更新主键导致500
2. scheduled_task.go: 新增 ListScheduledTasks + CancelScheduledTask handler
3. router.go: 注册 /tickets/scheduled/list 和 /tickets/:id/cancel-schedule 路由
4. WorkflowPage.tsx: 4处 wf.steps 添加 || [] 空值保护
This commit is contained in:
logan committed 2026-05-25 23:39:16 +08:00
1 parent 88e5f4e7ee
commit 2957075345
4 files changed
+146 -6

No files matched your search

+42 -2
View File
@@ -46,13 +46,53 @@ func UpdateInstanceGroup(c *gin.Context) {
return
}
var input map[string]interface{}
var input struct {
Name *string `json:"name"`
Description *string `json:"description"`
DBType *string `json:"db_type"`
Permissions *string `json:"permissions"`
IsActive *bool `json:"is_active"`
WorkflowID *int `json:"workflow_id"`
AccessType *string `json:"access_type"`
AllowedDatabases *string `json:"allowed_databases"`
}
if err := c.ShouldBindJSON(&input); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"detail": err.Error()})
return
}
if err := model.DB.Model(&group).Updates(input).Error; err != nil {
updates := map[string]interface{}{}
if input.Name != nil {
updates["name"] = *input.Name
}
if input.Description != nil {
updates["description"] = *input.Description
}
if input.DBType != nil {
updates["db_type"] = *input.DBType
}
if input.Permissions != nil {
updates["permissions"] = *input.Permissions
}
if input.IsActive != nil {
updates["is_active"] = *input.IsActive
}
if input.WorkflowID != nil {
updates["workflow_id"] = *input.WorkflowID
}
if input.AccessType != nil {
updates["access_type"] = *input.AccessType
}
if input.AllowedDatabases != nil {
updates["allowed_databases"] = *input.AllowedDatabases
}
if len(updates) == 0 {
c.JSON(http.StatusOK, enrichGroup(group))
return
}
if err := model.DB.Model(&group).Updates(updates).Error; err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"detail": err.Error()})
return
}