修复场地课表遗漏借用的问题
This commit is contained in:
1 parent
5872c06042
commit
54e1986ad0
3 files changed
+102
-4
No files matched your search
@@ -30,9 +30,33 @@ public sealed class VenueDisplaysController(
|
||||
term.Id, null, false, null, null, cancellationToken);
|
||||
var today = DateOnly.FromDateTime(DateTime.Now);
|
||||
var (week, day) = ClassroomReservationAvailabilityService.ResolveTeachingWeek(term, today);
|
||||
var entries = sheet?.Entries.Where(x => x.DayOfWeek == day && x.StartWeek <= week && x.EndWeek >= week &&
|
||||
var entries = sheet?.Entries
|
||||
.Where(x => x.DayOfWeek == day && x.StartWeek <= week && x.EndWeek >= week &&
|
||||
(x.WeekPattern == WeekPattern.All || x.WeekPattern == WeekPattern.Odd && week % 2 == 1 || x.WeekPattern == WeekPattern.Even && week % 2 == 0))
|
||||
.Select(x => new { x.CourseName, x.TeacherNames, x.ClassNames, x.StartPeriod, x.PeriodCount }) ?? [];
|
||||
.Select(x => new VenueDisplayClassroomEntry(
|
||||
x.CourseName,
|
||||
x.TeacherNames,
|
||||
x.ClassNames,
|
||||
x.StartPeriod,
|
||||
x.PeriodCount,
|
||||
false))
|
||||
.ToList() ?? [];
|
||||
var reservations = await db.ClassroomReservations.AsNoTracking()
|
||||
.Where(x => x.AcademicTermId == term.Id &&
|
||||
x.ClassroomId == classroomId &&
|
||||
x.Status == ClassroomReservationStatus.Approved &&
|
||||
x.ReservationDate == today)
|
||||
.OrderBy(x => x.StartPeriod)
|
||||
.Select(x => new VenueDisplayClassroomEntry(
|
||||
"教室借用",
|
||||
new[] { x.ApplicantName },
|
||||
new[] { x.Purpose },
|
||||
x.StartPeriod,
|
||||
x.PeriodCount,
|
||||
true))
|
||||
.ToListAsync(cancellationToken);
|
||||
entries.AddRange(reservations);
|
||||
entries.Sort((left, right) => left.StartPeriod.CompareTo(right.StartPeriod));
|
||||
return Ok(new { Classroom = classroom, Term = term.Name, Today = today, Week = week, Slots = sheet?.Slots ?? [], Entries = entries });
|
||||
}
|
||||
|
||||
@@ -59,3 +83,11 @@ public sealed class VenueDisplaysController(
|
||||
private Task<AcademicTerm?> CurrentTermAsync(CancellationToken cancellationToken) => db.AcademicTerms.AsNoTracking()
|
||||
.Where(x => x.IsEnabled && x.IsCurrent).FirstOrDefaultAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public sealed record VenueDisplayClassroomEntry(
|
||||
string CourseName,
|
||||
IEnumerable<string> TeacherNames,
|
||||
IEnumerable<string> ClassNames,
|
||||
int StartPeriod,
|
||||
int PeriodCount,
|
||||
bool IsReservation);
|
||||
Reference in new issue
Block a user