feat: able to delete logs now (close #486)

This commit is contained in:
JustSong
2023-09-17 17:09:56 +08:00
parent 3f9e723ce5
commit 39328d65c2
4 changed files with 85 additions and 18 deletions
+5
View File
@@ -169,3 +169,8 @@ func SumUsedToken(logType int, startTimestamp int64, endTimestamp int64, modelNa
tx.Where("type = ?", LogTypeConsume).Scan(&token)
return token
}
func DeleteOldLog(targetTimestamp int64) (int64, error) {
result := DB.Where("created_at < ?", targetTimestamp).Delete(&Log{})
return result.RowsAffected, result.Error
}