From 3752d42de85a6ff18fc703629b25c4ebdd81d184 Mon Sep 17 00:00:00 2001 From: lishuang Date: Sat, 2 Jan 2021 17:18:20 +0800 Subject: [PATCH] Fix the 0 day bin feature. --- code/rest/preference_controller.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/rest/preference_controller.go b/code/rest/preference_controller.go index bec1197..a56947c 100644 --- a/code/rest/preference_controller.go +++ b/code/rest/preference_controller.go @@ -14,6 +14,7 @@ type PreferenceController struct { BaseController preferenceDao *PreferenceDao matterDao *MatterDao + matterService *MatterService preferenceService *PreferenceService taskService *TaskService } @@ -30,6 +31,10 @@ func (this *PreferenceController) Init() { if b, ok := b.(*MatterDao); ok { this.matterDao = b } + b = core.CONTEXT.GetBean(this.matterService) + if b, ok := b.(*MatterService); ok { + this.matterService = b + } b = core.CONTEXT.GetBean(this.preferenceService) if b, ok := b.(*PreferenceService); ok { this.preferenceService = b @@ -136,6 +141,7 @@ func (this *PreferenceController) Edit(writer http.ResponseWriter, request *http } preference := this.preferenceDao.Fetch() + oldDeletedKeepDays := preference.DeletedKeepDays preference.Name = name preference.LogoUrl = logoUrl preference.FaviconUrl = faviconUrl @@ -149,6 +155,11 @@ func (this *PreferenceController) Edit(writer http.ResponseWriter, request *http preference = this.preferenceService.Save(preference) + //if changed the bin strategy. then trigger once. + if oldDeletedKeepDays != deletedKeepDays { + this.matterService.CleanExpiredDeletedMatters() + } + return this.Success(preference) }