diff --git a/src/service/alert.go b/src/service/alert.go index 5f44e269d36a91103e9d16584a0dfdde00431a7f..0967bf34fa01786742622d0d6569be813a3fa82f 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 }