diff --git a/app/mix/service/cronservice.go b/app/mix/service/cronservice.go index 307c7986..839b973f 100644 --- a/app/mix/service/cronservice.go +++ b/app/mix/service/cronservice.go @@ -109,6 +109,21 @@ func (s *CronService) ClearVeriCodeSendTimes() { scheduler.StartAsync() } +func (s *CronService) ClearMomentCreateTimes() { + loc, _ := time.LoadLocation("Asia/Shanghai") + scheduler := gocron.NewScheduler(loc) + + scheduler.Every(1).Day().At("00:00").Do(func() { + logger.Info("Clearing moment_create_times collection...") + ctx := &gin.Context{} + if err := _DefaultMomentCreateTimes.OpClear(ctx); err != nil { + logger.Error("Clear moment_create_times collection fail: %v", err) + } + logger.Info("moment_create_times collection has been cleared") + }) + scheduler.StartAsync() +} + // 统计每日报表 func (s *CronService) CreateDailyStatement() { loc, _ := time.LoadLocation("Asia/Shanghai")