排课优化 #3

Merged
biss merged 12 commits from codex/timetable-soft-constraints into master 2026-08-17 19:36:49 +08:00
12 changed files with 7417 additions and 10 deletions
Showing only changes of commit 9f533ad02a - Show all commits

No files matched your search

@@ -557,7 +557,7 @@ public sealed class BaseDataController(AppDbContext db, IAppCache cache) : Contr
.Select(x => new ClassroomListItem( .Select(x => new ClassroomListItem(
x.Id, x.Code, x.Name, x.BuildingId, x.Building!.CampusId, x.Id, x.Code, x.Name, x.BuildingId, x.Building!.CampusId,
x.Building.Name, x.Building.Campus!.Name, x.Capacity, x.Building.Name, x.Building.Campus!.Name, x.Capacity,
x.RoomType, x.TeachingVenueNature, x.Equipment, x.Floor, x.RoomType, x.TeachingVenueNature, x.Equipment,
x.IsEnabled, x.SortOrder)) x.IsEnabled, x.SortOrder))
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
return Ok(new PagedResult<ClassroomListItem>( return Ok(new PagedResult<ClassroomListItem>(
@@ -578,6 +578,7 @@ public sealed class BaseDataController(AppDbContext db, IAppCache cache) : Contr
x.Building.Name, x.Building.Name,
x.Building.Campus!.Name, x.Building.Campus!.Name,
x.Capacity, x.Capacity,
x.Floor,
x.RoomType, x.RoomType,
x.TeachingVenueNature, x.TeachingVenueNature,
x.Equipment, x.Equipment,
@@ -645,6 +646,7 @@ public sealed class BaseDataController(AppDbContext db, IAppCache cache) : Contr
Name = request.Name.Trim(), Name = request.Name.Trim(),
BuildingId = request.BuildingId, BuildingId = request.BuildingId,
Capacity = request.Capacity, Capacity = request.Capacity,
Floor = request.Floor,
RoomType = request.RoomType.Trim(), RoomType = request.RoomType.Trim(),
TeachingVenueNature = request.TeachingVenueNature == 0 TeachingVenueNature = request.TeachingVenueNature == 0
? TeachingVenueNature.GeneralClassroom ? TeachingVenueNature.GeneralClassroom
@@ -668,6 +670,7 @@ public sealed class BaseDataController(AppDbContext db, IAppCache cache) : Contr
ApplyCatalog(entity, request); ApplyCatalog(entity, request);
entity.BuildingId = request.BuildingId; entity.BuildingId = request.BuildingId;
entity.Capacity = request.Capacity; entity.Capacity = request.Capacity;
entity.Floor = request.Floor;
entity.RoomType = request.RoomType.Trim(); entity.RoomType = request.RoomType.Trim();
entity.TeachingVenueNature = request.TeachingVenueNature == 0 entity.TeachingVenueNature = request.TeachingVenueNature == 0
? TeachingVenueNature.GeneralClassroom ? TeachingVenueNature.GeneralClassroom
@@ -822,6 +825,7 @@ public sealed record ClassroomRequest(
string Code, string Name, int SortOrder, bool IsEnabled, string Code, string Name, int SortOrder, bool IsEnabled,
Guid BuildingId, Guid BuildingId,
[Range(1, 1000)] int Capacity, [Range(1, 1000)] int Capacity,
[Range(1, 99)] int Floor,
[Required, MaxLength(40)] string RoomType, [Required, MaxLength(40)] string RoomType,
TeachingVenueNature TeachingVenueNature, TeachingVenueNature TeachingVenueNature,
[MaxLength(300)] string? Equipment) [MaxLength(300)] string? Equipment)
@@ -879,6 +883,7 @@ public sealed record ClassroomListItem(
string BuildingName, string BuildingName,
string CampusName, string CampusName,
int Capacity, int Capacity,
int Floor,
string RoomType, string RoomType,
TeachingVenueNature TeachingVenueNature, TeachingVenueNature TeachingVenueNature,
string? Equipment, string? Equipment,
@@ -44,6 +44,7 @@ public sealed class Classroom : CatalogEntity
{ {
public Guid BuildingId { get; set; } public Guid BuildingId { get; set; }
public Building? Building { get; set; } public Building? Building { get; set; }
public int Floor { get; set; } = 1;
public int Capacity { get; set; } public int Capacity { get; set; }
public string RoomType { get; set; } = "普通教室"; public string RoomType { get; set; } = "普通教室";
public TeachingVenueNature TeachingVenueNature { get; set; } = public TeachingVenueNature TeachingVenueNature { get; set; } =
@@ -258,11 +258,14 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
.HasForeignKey(x => x.CampusId) .HasForeignKey(x => x.CampusId)
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
builder.Entity<Classroom>() builder.Entity<Classroom>(entity =>
.HasOne(x => x.Building) {
entity.Property(x => x.Floor).HasDefaultValue(1);
entity.HasOne(x => x.Building)
.WithMany() .WithMany()
.HasForeignKey(x => x.BuildingId) .HasForeignKey(x => x.BuildingId)
.OnDelete(DeleteBehavior.Restrict); .OnDelete(DeleteBehavior.Restrict);
});
builder.Entity<AcademicTerm>(entity => builder.Entity<AcademicTerm>(entity =>
{ {
Loaded 3 of 12 files, more files were not shown because too many files have changed in this diff. Show more