diff --git a/cmd/dashboard/controller/cron.go b/cmd/dashboard/controller/cron.go index 71be0a1..9084fdf 100644 --- a/cmd/dashboard/controller/cron.go +++ b/cmd/dashboard/controller/cron.go @@ -188,5 +188,6 @@ func batchDeleteCron(c *gin.Context) (any, error) { } singleton.OnDeleteCron(cr) + singleton.UpdateCronList() return nil, nil } diff --git a/model/cron.go b/model/cron.go index de3cbd9..e79ee5d 100644 --- a/model/cron.go +++ b/model/cron.go @@ -33,6 +33,15 @@ type Cron struct { ServersRaw string `json:"-"` } +func (c *Cron) BeforeSave(tx *gorm.DB) error { + if data, err := utils.Json.Marshal(c.Servers); err != nil { + return err + } else { + c.ServersRaw = string(data) + } + return nil +} + func (c *Cron) AfterFind(tx *gorm.DB) error { return utils.Json.Unmarshal([]byte(c.ServersRaw), &c.Servers) } diff --git a/model/cron_api.go b/model/cron_api.go index a124ecf..1d82d22 100644 --- a/model/cron_api.go +++ b/model/cron_api.go @@ -1,7 +1,6 @@ package model type CronForm struct { - ID uint64 `json:"id,omitempty"` TaskType uint8 `json:"task_type,omitempty" default:"0"` // 0:计划任务 1:触发任务 Name string `json:"name,omitempty" minLength:"1"` Scheduler string `json:"scheduler,omitempty"` diff --git a/model/ddns.go b/model/ddns.go index e38d947..8fcc934 100644 --- a/model/ddns.go +++ b/model/ddns.go @@ -1,8 +1,6 @@ package model import ( - "strings" - "github.com/naiba/nezha/pkg/utils" "gorm.io/gorm" ) @@ -50,8 +48,5 @@ func (d *DDNSProfile) BeforeSave(tx *gorm.DB) error { } func (d *DDNSProfile) AfterFind(tx *gorm.DB) error { - if d.DomainsRaw != "" { - d.Domains = strings.Split(d.DomainsRaw, ",") - } - return nil + return utils.Json.Unmarshal([]byte(d.DomainsRaw), &d.Domains) }