From efa082f6ed13380293a1b1f14babd7a9ee15807a Mon Sep 17 00:00:00 2001 From: taolx0 Date: Fri, 30 Aug 2024 13:36:29 +0800 Subject: [PATCH] chore:After updating the blacklist/whitelist records, reset the match count and last update time fields. --- sqle/api/controller/v1/blacklist.go | 5 +++++ sqle/api/controller/v1/sql_whitelist.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/sqle/api/controller/v1/blacklist.go b/sqle/api/controller/v1/blacklist.go index 39f0d0bd2..c5d636d4b 100644 --- a/sqle/api/controller/v1/blacklist.go +++ b/sqle/api/controller/v1/blacklist.go @@ -138,6 +138,11 @@ func UpdateBlacklist(c echo.Context) error { blacklist.Desc = *req.Desc } + if req.Content != nil || req.Type != nil { + blacklist.MatchedCount = 0 + blacklist.LastMatchTime = nil + } + err = s.Save(blacklist) if err != nil { return controller.JSONBaseErrorReq(c, err) diff --git a/sqle/api/controller/v1/sql_whitelist.go b/sqle/api/controller/v1/sql_whitelist.go index c553d6d8b..ac347dc20 100644 --- a/sqle/api/controller/v1/sql_whitelist.go +++ b/sqle/api/controller/v1/sql_whitelist.go @@ -106,6 +106,12 @@ func UpdateAuditWhitelistById(c echo.Context) error { if req.MatchType != nil { sqlWhitelist.MatchType = *req.MatchType } + + if req.Value != nil || req.MatchType != nil { + sqlWhitelist.MatchedCount = 0 + sqlWhitelist.LastMatchedTime = nil + } + if req.Desc != nil { sqlWhitelist.Desc = *req.Desc }