From bf01dba72b8dcabbbddaee674951403f7f733785 Mon Sep 17 00:00:00 2001 From: biss Date: Tue, 11 Aug 2026 12:04:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=AD=E8=AF=81=E4=B8=8B=E8=BD=BD=E5=AE=A1?= =?UTF-8?q?=E8=AE=A1=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/EvaluationsController.cs | 2 +- .../OfficialDocumentsController.cs | 17 +++++++++--- web/src/views/OfficialDocumentsView.vue | 26 +++++++++++++++++-- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/Jiaowu.Api/Controllers/EvaluationsController.cs b/src/Jiaowu.Api/Controllers/EvaluationsController.cs index b2729cd..8405d96 100644 --- a/src/Jiaowu.Api/Controllers/EvaluationsController.cs +++ b/src/Jiaowu.Api/Controllers/EvaluationsController.cs @@ -606,7 +606,7 @@ public sealed record EvaluationScoreRequest( public sealed record TeacherEvaluationTaskResult( Guid SetupId, - string Name, + string SetupName, TeacherEvaluationTask Task, int StudentCount, double AverageTotal, diff --git a/src/Jiaowu.Api/Controllers/OfficialDocumentsController.cs b/src/Jiaowu.Api/Controllers/OfficialDocumentsController.cs index e913d16..4e9e26c 100644 --- a/src/Jiaowu.Api/Controllers/OfficialDocumentsController.cs +++ b/src/Jiaowu.Api/Controllers/OfficialDocumentsController.cs @@ -227,14 +227,24 @@ public sealed class OfficialDocumentsController( [Authorize(Roles = Managers)] public async Task DownloadHistory( Guid id, - CancellationToken cancellationToken) + CancellationToken cancellationToken, + int page = 1, + int pageSize = 20) { + if (page < 1 || pageSize is < 1 or > 100) + return ValidationProblem("页码必须大于 0,且每页条数应在 1 至 100 之间。"); + if (!await AccessibleDocuments().AnyAsync(x => x.Id == id, cancellationToken)) return NotFound(); - return Ok(await db.OfficialDocumentDownloads.AsNoTracking() + var source = db.OfficialDocumentDownloads.AsNoTracking() .Where(x => x.OfficialDocumentId == id) .OrderByDescending(x => x.CreatedAt) + .ThenByDescending(x => x.Id); + var total = await source.CountAsync(cancellationToken); + var items = await source + .Skip((page - 1) * pageSize) + .Take(pageSize) .Select(x => new { x.Id, @@ -244,7 +254,8 @@ public sealed class OfficialDocumentsController( x.IpAddress, x.UserAgent }) - .ToListAsync(cancellationToken)); + .ToListAsync(cancellationToken); + return Ok(new PagedResult(items, total, page, pageSize)); } [HttpPost("{id:guid}/invalidate")] diff --git a/web/src/views/OfficialDocumentsView.vue b/web/src/views/OfficialDocumentsView.vue index c1feb3f..8e1a18e 100644 --- a/web/src/views/OfficialDocumentsView.vue +++ b/web/src/views/OfficialDocumentsView.vue @@ -49,6 +49,9 @@ const issueDialog = ref(false) const historyDrawer = ref(false) const historyLoading = ref(false) const downloadHistory = ref([]) +const historyPage = ref(1) +const historyTotal = ref(0) +const historyPageSize = 20 const selectedDocument = ref() const filters = reactive<{ type?: DocumentType; status?: DocumentStatus }>({}) const page = ref(1) @@ -192,10 +195,20 @@ async function reissue(row: OfficialDocumentRow) { async function showHistory(row: OfficialDocumentRow) { selectedDocument.value = row historyDrawer.value = true + historyPage.value = 1 + await loadHistory() +} + +async function loadHistory() { + if (!selectedDocument.value) return historyLoading.value = true try { - const { data } = await http.get(`/official-documents/${row.id}/downloads`) - downloadHistory.value = data + const { data } = await http.get( + `/official-documents/${selectedDocument.value.id}/downloads`, + { params: { page: historyPage.value, pageSize: historyPageSize } }, + ) + downloadHistory.value = data.items + historyTotal.value = data.total } catch (error) { ElMessage.error(apiErrorMessage(error)) } finally { @@ -355,6 +368,15 @@ onMounted(load) +