From 80969e8c59bb96ff3f70fe31c561559485f820c0 Mon Sep 17 00:00:00 2001 From: skyle1995 Date: Tue, 31 Mar 2026 10:28:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97=E6=B8=85?= =?UTF-8?q?=E7=90=86=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/admin/login_log.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/admin/login_log.go b/controllers/admin/login_log.go index ee80947..7c30adb 100644 --- a/controllers/admin/login_log.go +++ b/controllers/admin/login_log.go @@ -10,6 +10,7 @@ import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" + "gorm.io/gorm" ) // ============================================================================ @@ -117,7 +118,7 @@ func LoginLogsClearHandler(c *gin.Context) { } // 物理删除所有登录日志 - if err := db.Where("type = ?", "admin").Delete(&models.LoginLog{}).Error; err != nil { + if err := db.Session(&gorm.Session{AllowGlobalUpdate: true}).Unscoped().Where("type = ? OR type = ? OR type IS NULL", "admin", "").Delete(&models.LoginLog{}).Error; err != nil { logrus.WithError(err).Error("Failed to clear login logs") loginLogBaseController.HandleInternalError(c, "清空登录日志失败", err) return