😎若日志数据为空则禁止导出

This commit is contained in:
zuohuaijun 2025-01-13 19:38:08 +08:00
parent be44f1806d
commit d8e7cc0444
2 changed files with 4 additions and 0 deletions

View File

@ -78,6 +78,8 @@ public class SysLogExService : IDynamicApiController, ITransient
u => u.CreateTime >= input.StartTime && u.CreateTime <= input.EndTime)
.OrderBy(u => u.CreateTime, OrderByType.Desc)
.Select<ExportLogDto>().ToListAsync();
if (logExList == null || logExList.Count < 1)
throw Oops.Oh("日志数据为空,导出已取消");
var res = await ((IExcelExporter)new ExcelExporter()).ExportAsByteArray(logExList);
return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "异常日志.xlsx" };

View File

@ -76,6 +76,8 @@ public class SysLogOpService : IDynamicApiController, ITransient
u => u.CreateTime >= input.StartTime && u.CreateTime <= input.EndTime)
.OrderBy(u => u.CreateTime, OrderByType.Desc)
.Select<ExportLogDto>().ToListAsync();
if (logOpList == null || logOpList.Count < 1)
throw Oops.Oh("日志数据为空,导出已取消");
var res = await ((IExcelExporter)new ExcelExporter()).ExportAsByteArray(logOpList);
return new FileStreamResult(new MemoryStream(res), "application/octet-stream") { FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "操作日志.xlsx" };