From 06cda6821a34dbc8895d2f07675d09fff9dd5ac8 Mon Sep 17 00:00:00 2001 From: akrike <1625167628@qq.com> Date: Wed, 5 Feb 2025 13:46:16 +0800 Subject: [PATCH] support push choice --- internal/app/repository/push.go | 5 +++++ internal/app/service/process.go | 3 ++- internal/app/service/push.go | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/app/repository/push.go b/internal/app/repository/push.go index 239bc6d..34d8d6f 100644 --- a/internal/app/repository/push.go +++ b/internal/app/repository/push.go @@ -31,3 +31,8 @@ func (p *pushRepository) DeletePushConfig(id int) error { Id: int64(id), }).Error } + +func (p *pushRepository) GetPushConfigByIds(ids []int) (result []model.Push) { + db.Model(&model.Push{}).Where("id in ?", ids).Find(&result) + return +} diff --git a/internal/app/service/process.go b/internal/app/service/process.go index c6d8cc0..147bc69 100644 --- a/internal/app/service/process.go +++ b/internal/app/service/process.go @@ -56,6 +56,7 @@ type ProcessBase struct { statuPush bool logReport bool cgroupEnable bool + PushIds []int memoryLimit *float32 cpuLimit *float32 } @@ -240,7 +241,7 @@ func (p *ProcessBase) push(message string) { "{$message}": message, "{$status}": strconv.Itoa(int(p.State.State)), } - PushService.Push(messagePlaceholders) + PushService.Push(p.Config.PushIds, messagePlaceholders) } } diff --git a/internal/app/service/push.go b/internal/app/service/push.go index 2624fc0..ebe3e00 100644 --- a/internal/app/service/push.go +++ b/internal/app/service/push.go @@ -13,8 +13,8 @@ type pushService struct{} var PushService = new(pushService) -func (p *pushService) Push(placeholders map[string]string) { - pl := repository.PushRepository.GetPushList() +func (p *pushService) Push(ids []int, placeholders map[string]string) { + pl := repository.PushRepository.GetPushConfigByIds(ids) for _, v := range pl { if v.Enable { if v.Method == http.MethodGet {