Skip to content

Commit 54765d6

Browse files
committed
fix: 修复sqlite无法执行truncate的问题
1 parent 4b7f48a commit 54765d6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

service/isql/operation_log_isql.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type OperationLogService struct{}
2121
func (s OperationLogService) SaveOperationLogChannel(olc <-chan *model.OperationLog) {
2222
// 只会在线程开启的时候执行一次
2323
Logs := make([]model.OperationLog, 0)
24-
//5s 自动同步一次
24+
// 5s 自动同步一次
2525
duration := 5 * time.Second
2626
timer := time.NewTimer(duration)
2727
defer timer.Stop()
@@ -35,7 +35,7 @@ func (s OperationLogService) SaveOperationLogChannel(olc <-chan *model.Operation
3535
Logs = make([]model.OperationLog, 0)
3636
timer.Reset(duration) // 入库重置定时器
3737
}
38-
case <-timer.C: //5s 自动同步一次
38+
case <-timer.C: // 5s 自动同步一次
3939
if len(Logs) > 0 {
4040
common.DB.Create(&Logs)
4141
Logs = make([]model.OperationLog, 0)
@@ -102,5 +102,5 @@ func (s OperationLogService) Delete(operationLogIds []uint) error {
102102

103103
// Clean 清空日志
104104
func (s OperationLogService) Clean() error {
105-
return common.DB.Exec("TRUNCATE TABLE operation_logs").Error
105+
return common.DB.Exec("DELETE FROM operation_logs").Error
106106
}

0 commit comments

Comments
 (0)