From bfa667584a998fb4001f68a626acc44db1552923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=98=AD?= <81747598+lan-yonghui@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:15:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BC=96=E8=BE=91=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=92=8C=E7=97=85=E6=AF=92=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=20(#7047?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #7039 --- backend/app/service/clam.go | 20 +++++++++++--------- backend/app/service/cronjob.go | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/backend/app/service/clam.go b/backend/app/service/clam.go index cb1b82a15..f318105f7 100644 --- a/backend/app/service/clam.go +++ b/backend/app/service/clam.go @@ -249,15 +249,17 @@ func (c *ClamService) Update(req dto.ClamUpdate) error { if err := clamRepo.Update(req.ID, upMap); err != nil { return err } - updateAlert := dto.CreateOrUpdateAlert{ - AlertTitle: req.AlertTitle, - AlertType: "clams", - AlertCount: req.AlertCount, - EntryID: clam.ID, - } - err := xpack.UpdateAlert(updateAlert) - if err != nil { - return err + if req.AlertCount != 0 { + updateAlert := dto.CreateOrUpdateAlert{ + AlertTitle: req.AlertTitle, + AlertType: "clams", + AlertCount: req.AlertCount, + EntryID: clam.ID, + } + err := xpack.UpdateAlert(updateAlert) + if err != nil { + return err + } } return nil } diff --git a/backend/app/service/cronjob.go b/backend/app/service/cronjob.go index 81dee96fa..2f700a3c3 100644 --- a/backend/app/service/cronjob.go +++ b/backend/app/service/cronjob.go @@ -316,15 +316,17 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error { if err != nil { return err } - updateAlert := dto.CreateOrUpdateAlert{ - AlertTitle: req.AlertTitle, - AlertType: cronModel.Type, - AlertCount: req.AlertCount, - EntryID: cronModel.ID, - } - err = xpack.UpdateAlert(updateAlert) - if err != nil { - return err + if req.AlertCount != 0 { + updateAlert := dto.CreateOrUpdateAlert{ + AlertTitle: req.AlertTitle, + AlertType: cronModel.Type, + AlertCount: req.AlertCount, + EntryID: cronModel.ID, + } + err = xpack.UpdateAlert(updateAlert) + if err != nil { + return err + } } return nil }