From 6c47d7fa338140971e24e48518348d01b94956cf Mon Sep 17 00:00:00 2001 From: Leufolium Date: Thu, 11 Apr 2024 19:37:04 +0800 Subject: [PATCH] by Robin at 20240411 --- app/mix/service/cronservice.go | 1 + app/mix/service/xxljob_tasks.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/mix/service/cronservice.go b/app/mix/service/cronservice.go index 01bbd362..8af0b457 100644 --- a/app/mix/service/cronservice.go +++ b/app/mix/service/cronservice.go @@ -57,6 +57,7 @@ func (s *CronService) Init(c any) (err error) { exec.RegTask("send_contact_customer_services_of_last_minute", s.SendContactCustomerServicesOfLastMinute) exec.RegTask("cancel_account_at_due_time", s.CancelAccountsAtDueTime) exec.RegTask("reload_moment_recomm_list", s.ReloadMomentRecommList) + exec.RegTask("clear_zone_moment_create_times", s.ClearZoneMomentCreateTimes) exec.LogHandler(customLogHandle) //注册任务handler diff --git a/app/mix/service/xxljob_tasks.go b/app/mix/service/xxljob_tasks.go index ed4d0295..e723925d 100644 --- a/app/mix/service/xxljob_tasks.go +++ b/app/mix/service/xxljob_tasks.go @@ -423,3 +423,14 @@ func (s *CronService) ReloadMomentRecommList(ctx context.Context, param *xxl.Run logger.Info("Refresh moment recommendation list cached in redis accomplished...") return "Refresh moment recommendation list cached in redis accomplished" } + +func (s *CronService) ClearZoneMomentCreateTimes(ctx context.Context, param *xxl.RunReq) (msg string) { + logger.Info("task %v param: %v log_id: %v", param.ExecutorHandler, param.ExecutorParams, xxl.Int64ToStr(param.LogID)) + logger.Info("Clearing zone_moment_create_times collection...") + if err := _DefaultZoneMomentCreateTimes.OpClear(&gin.Context{}); err != nil { + logger.Error("Clear zone_moment_create_times collection fail: %v", err) + return fmt.Sprintf("Clear zone_moment_create_times collection fail: %v", err) + } + logger.Info("zone_moment_create_times collection has been cleared") + return "zone_moment_create_times collection has been cleared" +}