using Dlhis.Entity.Common; using Kurisu.SqlSugar.Services; namespace Dlhis.ScheduledTask.CommonJobs; public class DelApiLogTaskJob { private readonly IDbContext _dbContext; private readonly ILogger _logger; public DelApiLogTaskJob(IDbContext dbContext, ILogger logger) { _dbContext = dbContext; _logger = logger; } public async Task RunAsync() { try { DateTime before = DateTime.Now.Date.AddDays(-7); await _dbContext.ChangeDb("log").Client.Deleteable().Where(x => x._ts <= before).ExecuteCommandAsync(); } catch (Exception ex) { _logger.LogError(ex, "删除日志异常:{message}", ex.Message); } } }