From e36a02ea59255d40d8921373ced5a8dd90fb3028 Mon Sep 17 00:00:00 2001 From: biss Date: Sun, 9 Aug 2026 16:02:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E8=AF=BE=E8=A1=A8=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=9C=A8=E5=90=8C=E4=B8=80=E4=BA=8B=E5=8A=A1=E5=86=85?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=AE=9E=E9=99=85=E5=91=A8=E6=AC=A1=E8=AF=BE?= =?UTF-8?q?=E6=AC=A1=E6=98=8E=E7=BB=86=E3=80=82=20=E5=B7=B2=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E7=9A=84=E8=B0=83=E8=AF=BE=E3=80=81=E5=81=9C=E8=AF=BE?= =?UTF-8?q?=E3=80=81=E8=A1=A5=E8=AF=BE=E3=80=81=E4=BB=A3=E8=AF=BE=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E9=87=8D=E5=BB=BA=E5=8F=97=E5=BD=B1=E5=93=8D?= =?UTF-8?q?=E6=95=99=E5=AD=A6=E4=BB=BB=E5=8A=A1=E6=89=80=E5=9C=A8=E5=B7=B2?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E8=AF=BE=E8=A1=A8=E7=9A=84=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E6=8A=95=E5=BD=B1=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CourseAdjustmentsController.cs | 3 +++ .../Timetables/PublishedTimetableProjectionService.cs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Jiaowu.Api/Controllers/CourseAdjustmentsController.cs b/src/Jiaowu.Api/Controllers/CourseAdjustmentsController.cs index 6c4bc77..2377af2 100644 --- a/src/Jiaowu.Api/Controllers/CourseAdjustmentsController.cs +++ b/src/Jiaowu.Api/Controllers/CourseAdjustmentsController.cs @@ -3,6 +3,7 @@ using Jiaowu.Api.Domain.Academic; using Jiaowu.Api.Domain.Identity; using Jiaowu.Api.Infrastructure.Auth; using Jiaowu.Api.Infrastructure.Persistence; +using Jiaowu.Api.Infrastructure.Timetables; using Jiaowu.Api.Infrastructure.Scheduling; using Jiaowu.Api.Infrastructure.Teaching; using Microsoft.AspNetCore.Authorization; @@ -286,6 +287,8 @@ public sealed class CourseAdjustmentsController( db.CourseAdjustments.Add(adj); await db.SaveChangesAsync(cancellationToken); + await new PublishedTimetableProjectionService(db) + .RebuildPublishedPlansForTaskAsync(adj.TeachingTaskId, cancellationToken); if (request.Submit) { diff --git a/src/Jiaowu.Api/Infrastructure/Timetables/PublishedTimetableProjectionService.cs b/src/Jiaowu.Api/Infrastructure/Timetables/PublishedTimetableProjectionService.cs index 3465c9d..72d3534 100644 --- a/src/Jiaowu.Api/Infrastructure/Timetables/PublishedTimetableProjectionService.cs +++ b/src/Jiaowu.Api/Infrastructure/Timetables/PublishedTimetableProjectionService.cs @@ -6,6 +6,17 @@ namespace Jiaowu.Api.Infrastructure.Timetables; public sealed class PublishedTimetableProjectionService(AppDbContext db) { + public async Task RebuildPublishedPlansForTaskAsync(Guid teachingTaskId, CancellationToken cancellationToken) + { + var plans = await db.SchedulePlans + .Where(plan => plan.Status == SchedulePlanStatus.Published && + plan.Entries.Any(entry => entry.TeachingTaskId == teachingTaskId)) + .Include(plan => plan.Entries) + .ToListAsync(cancellationToken); + foreach (var plan in plans) + await RebuildAsync(plan, cancellationToken); + } + public async Task RebuildAsync(SchedulePlan plan, CancellationToken cancellationToken) { var previous = db.PublishedScheduleOccurrences.Where(x => x.SchedulePlanId == plan.Id);