You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.4 KiB
65 lines
2.4 KiB
// 大名科技(天津)有限公司版权所有 电话:18020030720 QQ:515096995
|
|
//
|
|
// 此源代码遵循位于源代码树根目录中的 LICENSE 文件的许可证
|
|
|
|
namespace Admin.NET.Core.Service;
|
|
|
|
/// <summary>
|
|
/// 系统异常日志服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings(Order = 350)]
|
|
public class SysLogExService : IDynamicApiController, ITransient
|
|
{
|
|
private readonly SqlSugarRepository<SysLogEx> _sysLogExRep;
|
|
|
|
public SysLogExService(SqlSugarRepository<SysLogEx> sysLogExRep)
|
|
{
|
|
_sysLogExRep = sysLogExRep;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取异常日志分页列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[SuppressMonitor]
|
|
[DisplayName("获取异常日志分页列表")]
|
|
public async Task<SqlSugarPagedList<SysLogEx>> Page(PageLogInput input)
|
|
{
|
|
return await _sysLogExRep.AsQueryable()
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.StartTime.ToString()), u => u.CreateTime >= input.StartTime)
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.EndTime.ToString()), u => u.CreateTime <= input.EndTime)
|
|
//.OrderBy(u => u.CreateTime, OrderByType.Desc)
|
|
.OrderBuilder(input)
|
|
.ToPagedListAsync(input.Page, input.PageSize);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 清空异常日志
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[ApiDescriptionSettings(Name = "Clear"), HttpPost]
|
|
[DisplayName("清空异常日志")]
|
|
public async Task<bool> Clear()
|
|
{
|
|
return await _sysLogExRep.DeleteAsync(u => u.Id > 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出异常日志
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[ApiDescriptionSettings(Name = "Export"), NonUnify]
|
|
[DisplayName("导出异常日志")]
|
|
public async Task<IActionResult> ExportLogEx(LogInput input)
|
|
{
|
|
var logExList = await _sysLogExRep.AsQueryable()
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.StartTime.ToString()) && !string.IsNullOrWhiteSpace(input.EndTime.ToString()),
|
|
u => u.CreateTime >= input.StartTime && u.CreateTime <= input.EndTime)
|
|
.OrderBy(u => u.CreateTime, OrderByType.Desc)
|
|
.Select<ExportLogDto>().ToListAsync();
|
|
|
|
IExcelExporter excelExporter = new ExcelExporter();
|
|
var res = await excelExporter.ExportAsByteArray(logExList);
|
|
return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "异常日志.xlsx" };
|
|
}
|
|
}
|