From a03041d6fd64e56a27f74f3076e940db11bdbc0c Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 28 Jun 2019 18:09:51 +0800 Subject: [PATCH] =?UTF-8?q?-=20SaveStoresVendorSnapshot=E4=B8=AD=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E4=B8=A4=E5=A4=A9=E5=89=8D=E7=9A=84=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=BF=AB=E7=85=A7=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/store.go | 3 +++ business/model/dao/store.go | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index e401b6464..94982a49e 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1294,6 +1294,9 @@ func SaveStoresVendorSnapshot(db *dao.DaoDB, snapshotAt time.Time, curSnapshotLi } } }() + if err = dao.DeleteVendorStoreSnapshot(db, snapshotAt.Add(-48*time.Hour)); err != nil { + return err + } for _, v := range curSnapshotList { v.SnapshotAt = snapshotAt diff --git a/business/model/dao/store.go b/business/model/dao/store.go index a98fcfaf0..5ec3626c6 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -284,3 +284,12 @@ func GetVendorStoreSnapshot(db *DaoDB, excludeSnapshotAt time.Time) (snapshotLis err = GetRows(db, &snapshotList, sql, time.Now().Add(-48*time.Hour), excludeSnapshotAt) return snapshotList, err } + +func DeleteVendorStoreSnapshot(db *DaoDB, minSnapshotAt time.Time) (err error) { + _, err = ExecuteSQL(db, ` + DELETE t1 + FROM vendor_store_snapshot t1 + WHERE t1.snapshot_at < ? + `, minSnapshotAt) + return err +}