文件下载名称调优

This commit is contained in:
biss committed 2026-08-21 17:34:22 +08:00
1 parent cd5aa624db
commit 0e02d446ba
19 files changed
+116 -37

No files matched your search

@@ -8,6 +8,7 @@ using Jiaowu.Api.Domain.Academic;
using Jiaowu.Api.Domain.Identity;
using Jiaowu.Api.Infrastructure.Auth;
using Jiaowu.Api.Infrastructure.Excel;
using Jiaowu.Api.Infrastructure.Files;
using Jiaowu.Api.Infrastructure.Persistence;
using Jiaowu.Api.Infrastructure.Teaching;
using Microsoft.AspNetCore.Authorization;
@@ -566,7 +567,7 @@ public sealed class AttendanceController(
statusLabels.GetValueOrDefault(r.Status, "出勤"), r.Notes
}).ToList<IReadOnlyList<object?>>());
return File(bytes, ExcelWorkbookHelper.ContentType,
$"考勤表-{sheetData.TaskNumber}-{sheetData.AttendanceDate:yyyyMMdd}.xlsx");
DownloadFileName.Export("考勤表", ".xlsx", sheetData.TaskNumber, sheetData.AttendanceDate.ToString("yyyyMMdd")));
}
[HttpGet("tasks/{teachingTaskId:guid}/statistics")]
@@ -596,7 +597,7 @@ public sealed class AttendanceController(
return File(
bytes,
ExcelWorkbookHelper.ContentType,
$"课程考勤统计-{statistics.Course.TaskNumber}.xlsx");
DownloadFileName.Export("课程考勤统计", ".xlsx", statistics.Course.TaskNumber));
}
[HttpPost("sheets/{id:guid}/submit")]
@@ -3,6 +3,7 @@ using Jiaowu.Api.Domain.Common;
using Jiaowu.Api.Domain.Identity;
using Jiaowu.Api.Infrastructure.Caching;
using Jiaowu.Api.Infrastructure.Excel;
using Jiaowu.Api.Infrastructure.Files;
using Jiaowu.Api.Infrastructure.Persistence;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -46,7 +47,7 @@ public sealed class BaseDataExcelController(AppDbContext db, IAppCache cache) :
"状态填写“启用”或“停用”;是/否字段填写“是”或“否”。",
"整批数据会先校验,任一行有误时均不会写入。"
]);
return File(bytes, ExcelWorkbookHelper.ContentType, $"{KindName(kind)}导入模板.xlsx");
return File(bytes, ExcelWorkbookHelper.ContentType, DownloadFileName.Template(KindName(kind), ".xlsx"));
}
[HttpGet("{kind}/export")]
@@ -56,7 +57,7 @@ public sealed class BaseDataExcelController(AppDbContext db, IAppCache cache) :
var rows = await GetExportRowsAsync(kind, cancellationToken);
var bytes = ExcelWorkbookHelper.Create(KindName(kind), headers, rows);
return File(bytes, ExcelWorkbookHelper.ContentType,
$"{KindName(kind)}-{DateTime.Now:yyyyMMdd-HHmm}.xlsx");
DownloadFileName.Export(KindName(kind), ".xlsx"));
}
[HttpPost("{kind}/import")]
@@ -6,6 +6,7 @@ using Jiaowu.Api.Domain.Identity;
using Jiaowu.Api.Infrastructure.Auth;
using Jiaowu.Api.Infrastructure.CourseSelection;
using Jiaowu.Api.Infrastructure.Excel;
using Jiaowu.Api.Infrastructure.Files;
using Jiaowu.Api.Infrastructure.Graduation;
using Jiaowu.Api.Infrastructure.Persistence;
using Jiaowu.Api.Infrastructure.Teaching;
@@ -76,7 +77,7 @@ public sealed class CourseSelectionsController(
"专业", "行政班", "年级", "修读状态", "修读类型", "选入时间", "退选时间", "免修审批"
], rows);
return File(bytes, ExcelWorkbookHelper.ContentType,
$"修读课程名单-{DateTime.Now:yyyyMMdd-HHmm}.xlsx");
DownloadFileName.Export("修读课程名单", ".xlsx"));
}
[HttpGet("enrollments/students")]
@@ -137,7 +138,7 @@ public sealed class CourseSelectionsController(
"学号", "姓名", "专业", "行政班", "年级", "修读课程", "在修学分"
], rows);
return File(bytes, ExcelWorkbookHelper.ContentType,
$"学生修读汇总-{DateTime.Now:yyyyMMdd-HHmm}.xlsx");
DownloadFileName.Export("学生修读汇总", ".xlsx"));
}
[HttpGet("rounds")]
@@ -1864,7 +1865,7 @@ public sealed class CourseSelectionsController(
return File(
bytes,
ExcelWorkbookHelper.ContentType,
$"教学班名单-{task.TaskNumber}.xlsx");
DownloadFileName.Export("教学班名单", ".xlsx", task.TaskNumber));
}
[HttpGet("offerings/{id:guid}/roster/export.xlsx")]
@@ -1920,7 +1921,7 @@ public sealed class CourseSelectionsController(
s.EnrolledAt.ToString("yyyy-MM-dd HH:mm")
}).ToList<IReadOnlyList<object?>>());
return File(bytes, ExcelWorkbookHelper.ContentType,
$"选课名单-{offering.TaskNumber}.xlsx");
DownloadFileName.Export("选课名单", ".xlsx", offering.TaskNumber));
}
private IQueryable<CourseSelectionOffering> ScopedOfferings()
Loaded 3 of 19 files, more files were not shown because too many files have changed in this diff. Show more