using Furion.DependencyInjection; using Furion.DynamicApiController; using GDZZ.Core.Entity; using Microsoft.AspNetCore.Mvc; using SqlSugar; using System; using System.Threading.Tasks; namespace GDZZ.Core.Service; /// /// 异常日志服务 /// [ApiDescriptionSettings(Name = "ExLog", Order = 100)] public class SysExLogService : ISysExLogService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _sysExLogRep; // 操作日志表仓储 public SysExLogService(SqlSugarRepository sysExLogRep) { _sysExLogRep = sysExLogRep; } /// /// 分页查询异常日志 /// /// /// [HttpGet("/sysExLog/page")] public async Task QueryExLogPageList([FromQuery] ExLogInput input) { var exLogs = await _sysExLogRep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.ClassName), u => u.ClassName == input.ClassName) .WhereIF(!string.IsNullOrWhiteSpace(input.MethodName), u => u.MethodName == input.MethodName) .WhereIF(!string.IsNullOrWhiteSpace(input.ExceptionMsg), u => u.ExceptionMsg.Contains(input.ExceptionMsg.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.SearchBeginTime), u => u.ExceptionTime >= DateTime.Parse(input.SearchBeginTime.Trim()) && u.ExceptionTime <= DateTime.Parse(input.SearchEndTime.Trim())) .OrderBy(u => u.Id, OrderByType.Desc) .Select() .ToPagedListAsync(input.PageNo, input.PageSize); return exLogs.XnPagedResult(); } /// /// 清空异常日志 /// /// [HttpPost("/sysExLog/delete")] public async Task ClearExLog() { await _sysExLogRep.DeleteAsync(m => true); } }