From 3c15977fcb8b35674891b337ce0a83ea948687ae Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 12 Jul 2022 16:15:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=88=87=E7=89=87=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96=20(#69)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/isql/operation_log_isql.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/service/isql/operation_log_isql.go b/service/isql/operation_log_isql.go index d50f7c6..0d289e8 100644 --- a/service/isql/operation_log_isql.go +++ b/service/isql/operation_log_isql.go @@ -36,10 +36,11 @@ func (s OperationLogService) SaveOperationLogChannel(olc <-chan *model.Operation timer.Reset(duration) // 入库重置定时器 } case <-timer.C: //5s 自动同步一次 - common.DB.Create(&Logs) - Logs = make([]model.OperationLog, 0) + if len(Logs) > 0 { + common.DB.Create(&Logs) + Logs = make([]model.OperationLog, 0) + } timer.Reset(duration) // 入库重置定时器 - } } }