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

This commit is contained in:
JustSong
2023-09-17 17:09:56 +08:00
parent 4335f005a6
commit 328aa68255
4 changed files with 85 additions and 18 deletions

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
}