From 0de4349f26e61fc534e3aca2b4bb8804f9e34c7f Mon Sep 17 00:00:00 2001 From: like Date: Thu, 20 Jul 2023 11:35:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E5=A4=84=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/alert.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/service/alert.go b/src/service/alert.go index 5f44e26..0967bf3 100644 --- a/src/service/alert.go +++ b/src/service/alert.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/jinzhu/copier" json "github.com/json-iterator/go" "github.com/olivere/elastic/v7" "github.com/opensearch-project/opensearch-go/opensearchapi" @@ -15,11 +16,13 @@ import ( "gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/client" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/conf" "gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/jsontime" + "gitlab.wodcloud.com/smart-operation/so-operation-api/src/util" "go.uber.org/zap" "io" "log" "net/http" "strings" + "time" "xorm.io/xorm" ) @@ -404,9 +407,18 @@ func (a *AlertSvc) Update(req request.UpdateAlert) error { func (a *AlertSvc) BatchPushAlert(session *xorm.Session, req request.BatchPushAlert) error { now := jsontime.Now() - _ = now + data := entity.PushRecord{ + CreatedBy: a.User.SystemAccount, + CreatedAt: now, + UpdatedBy: a.User.SystemAccount, + UpdatedAt: now, + } + _ = copier.Copy(&data, &req) + data.NotifyMethod = util.ConvertToString(req.NotifyMethod) + data.SystemAccount = util.ConvertToString(req.NotifyRecipients) // 循环查询 // TODO 批量推送用户告警 conf.Logger.Info("batch push", zap.Any("payload", req)) + time.Sleep(time.Second) return nil } @@ -429,6 +441,7 @@ func (a *AlertSvc) BatchCloseAlert(req request.BatchCloseAlert) (err error) { } } conf.Logger.Info("batch close", zap.Any("payload", req)) + time.Sleep(time.Second) return } @@ -518,5 +531,6 @@ func (a *AlertSvc) DisposeAlert(req request.DisposeAlert) (err error) { if err != nil { return } + time.Sleep(time.Second) return nil } -- 2.26.0