From 01ed60fcb7424f02fc81027727eb3d76bf620369 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 1 Jun 2023 15:05:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=B7=B2=E5=81=9C=E6=AD=A2=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#1218)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/cornjob.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/app/service/cornjob.go b/backend/app/service/cornjob.go index bdec47962..132b10732 100644 --- a/backend/app/service/cornjob.go +++ b/backend/app/service/cornjob.go @@ -221,16 +221,20 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error { if err != nil { return constant.ErrRecordNotFound } + upMap := make(map[string]interface{}) cronjob.EntryID = cronModel.EntryID cronjob.Type = cronModel.Type cronjob.Spec = loadSpec(cronjob) - newEntryID, err := u.StartJob(&cronjob) - if err != nil { - return err + if cronModel.Status == constant.StatusEnable { + newEntryID, err := u.StartJob(&cronjob) + if err != nil { + return err + } + upMap["entry_id"] = newEntryID + } else { + global.Cron.Remove(cron.EntryID(cronjob.EntryID)) } - upMap := make(map[string]interface{}) - upMap["entry_id"] = newEntryID upMap["name"] = req.Name upMap["spec"] = cronjob.Spec upMap["script"] = req.Script @@ -239,6 +243,7 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error { upMap["day"] = req.Day upMap["hour"] = req.Hour upMap["minute"] = req.Minute + upMap["second"] = req.Second upMap["website"] = req.Website upMap["exclusion_rules"] = req.ExclusionRules upMap["db_name"] = req.DBName