优化考试排考

This commit is contained in:
2026-07-27 19:31:19 +08:00 Unverified
parent 64decdab7e
commit c3e8a42641
14 changed files with 7013 additions and 272 deletions
@@ -0,0 +1,196 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
/// <inheritdoc />
public partial class ExamRoomMixing : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ExamRooms",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false),
ExamPlanId = table.Column<Guid>(type: "char(36)", nullable: false),
CourseId = table.Column<Guid>(type: "char(36)", nullable: false),
ClassroomId = table.Column<Guid>(type: "char(36)", nullable: false),
ExamDate = table.Column<DateTime>(type: "date", nullable: false),
StartPeriod = table.Column<int>(type: "int", nullable: false),
PeriodCount = table.Column<int>(type: "int", nullable: false),
StartsAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
EndsAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
RequiredInvigilatorCount = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExamRooms", x => x.Id);
table.ForeignKey(
name: "FK_ExamRooms_Classrooms_ClassroomId",
column: x => x.ClassroomId,
principalTable: "Classrooms",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_ExamRooms_Courses_CourseId",
column: x => x.CourseId,
principalTable: "Courses",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_ExamRooms_ExamPlans_ExamPlanId",
column: x => x.ExamPlanId,
principalTable: "ExamPlans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "ExamRoomInvigilators",
columns: table => new
{
ExamRoomId = table.Column<Guid>(type: "char(36)", nullable: false),
TeacherId = table.Column<Guid>(type: "char(36)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExamRoomInvigilators", x => new { x.ExamRoomId, x.TeacherId });
table.ForeignKey(
name: "FK_ExamRoomInvigilators_ExamRooms_ExamRoomId",
column: x => x.ExamRoomId,
principalTable: "ExamRooms",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ExamRoomInvigilators_Teachers_TeacherId",
column: x => x.TeacherId,
principalTable: "Teachers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "ExamRoomSessions",
columns: table => new
{
ExamRoomId = table.Column<Guid>(type: "char(36)", nullable: false),
ExamSessionId = table.Column<Guid>(type: "char(36)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExamRoomSessions", x => new { x.ExamRoomId, x.ExamSessionId });
table.ForeignKey(
name: "FK_ExamRoomSessions_ExamRooms_ExamRoomId",
column: x => x.ExamRoomId,
principalTable: "ExamRooms",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ExamRoomSessions_ExamSessions_ExamSessionId",
column: x => x.ExamSessionId,
principalTable: "ExamSessions",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "ExamSeats",
columns: table => new
{
ExamRoomId = table.Column<Guid>(type: "char(36)", nullable: false),
StudentId = table.Column<Guid>(type: "char(36)", nullable: false),
ExamSessionId = table.Column<Guid>(type: "char(36)", nullable: false),
SeatNumber = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExamSeats", x => new { x.ExamRoomId, x.StudentId });
table.ForeignKey(
name: "FK_ExamSeats_ExamRooms_ExamRoomId",
column: x => x.ExamRoomId,
principalTable: "ExamRooms",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ExamSeats_ExamSessions_ExamSessionId",
column: x => x.ExamSessionId,
principalTable: "ExamSessions",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_ExamSeats_Students_StudentId",
column: x => x.StudentId,
principalTable: "Students",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_ExamRoomInvigilators_TeacherId",
table: "ExamRoomInvigilators",
column: "TeacherId");
migrationBuilder.CreateIndex(
name: "IX_ExamRooms_ClassroomId",
table: "ExamRooms",
column: "ClassroomId");
migrationBuilder.CreateIndex(
name: "IX_ExamRooms_CourseId",
table: "ExamRooms",
column: "CourseId");
migrationBuilder.CreateIndex(
name: "IX_ExamRooms_Plan_Room_Time",
table: "ExamRooms",
columns: new[] { "ExamPlanId", "ClassroomId", "StartsAt" });
migrationBuilder.CreateIndex(
name: "IX_ExamRooms_Plan_Time",
table: "ExamRooms",
columns: new[] { "ExamPlanId", "StartsAt" });
migrationBuilder.CreateIndex(
name: "IX_ExamRoomSessions_SessionId",
table: "ExamRoomSessions",
column: "ExamSessionId");
migrationBuilder.CreateIndex(
name: "IX_ExamSeats_StudentId",
table: "ExamSeats",
column: "StudentId");
migrationBuilder.CreateIndex(
name: "UX_ExamSeats_Session_Student",
table: "ExamSeats",
columns: new[] { "ExamSessionId", "StudentId" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ExamRoomInvigilators");
migrationBuilder.DropTable(
name: "ExamRoomSessions");
migrationBuilder.DropTable(
name: "ExamSeats");
migrationBuilder.DropTable(
name: "ExamRooms");
}
}
}
@@ -1558,6 +1558,119 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
b.ToTable("ExamPlans");
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamRoomAssignment", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<Guid>("ClassroomId")
.HasColumnType("char(36)");
b.Property<Guid>("CourseId")
.HasColumnType("char(36)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<DateTime>("EndsAt")
.HasColumnType("datetime(6)");
b.Property<DateTime>("ExamDate")
.HasColumnType("date");
b.Property<Guid>("ExamPlanId")
.HasColumnType("char(36)");
b.Property<int>("PeriodCount")
.HasColumnType("int");
b.Property<int>("RequiredInvigilatorCount")
.HasColumnType("int");
b.Property<int>("StartPeriod")
.HasColumnType("int");
b.Property<DateTime>("StartsAt")
.HasColumnType("datetime(6)");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("datetime(6)");
b.HasKey("Id");
b.HasIndex("ClassroomId");
b.HasIndex("CourseId")
.HasDatabaseName("IX_ExamRooms_CourseId");
b.HasIndex("ExamPlanId", "StartsAt")
.HasDatabaseName("IX_ExamRooms_Plan_Time");
b.HasIndex("ExamPlanId", "ClassroomId", "StartsAt")
.HasDatabaseName("IX_ExamRooms_Plan_Room_Time");
b.ToTable("ExamRooms", (string)null);
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamRoomInvigilator", b =>
{
b.Property<Guid>("ExamRoomId")
.HasColumnType("char(36)");
b.Property<Guid>("TeacherId")
.HasColumnType("char(36)");
b.HasKey("ExamRoomId", "TeacherId");
b.HasIndex("TeacherId")
.HasDatabaseName("IX_ExamRoomInvigilators_TeacherId");
b.ToTable("ExamRoomInvigilators", (string)null);
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamRoomSession", b =>
{
b.Property<Guid>("ExamRoomId")
.HasColumnType("char(36)");
b.Property<Guid>("ExamSessionId")
.HasColumnType("char(36)");
b.HasKey("ExamRoomId", "ExamSessionId");
b.HasIndex("ExamSessionId")
.HasDatabaseName("IX_ExamRoomSessions_SessionId");
b.ToTable("ExamRoomSessions", (string)null);
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamSeatAssignment", b =>
{
b.Property<Guid>("ExamRoomId")
.HasColumnType("char(36)");
b.Property<Guid>("StudentId")
.HasColumnType("char(36)");
b.Property<Guid>("ExamSessionId")
.HasColumnType("char(36)");
b.Property<int>("SeatNumber")
.HasColumnType("int");
b.HasKey("ExamRoomId", "StudentId");
b.HasIndex("StudentId")
.HasDatabaseName("IX_ExamSeats_StudentId");
b.HasIndex("ExamSessionId", "StudentId")
.IsUnique()
.HasDatabaseName("UX_ExamSeats_Session_Student");
b.ToTable("ExamSeats", (string)null);
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamSession", b =>
{
b.Property<Guid>("Id")
@@ -4097,6 +4210,98 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
b.Navigation("AcademicTerm");
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamRoomAssignment", b =>
{
b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom")
.WithMany()
.HasForeignKey("ClassroomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("Jiaowu.Api.Domain.Academic.Course", "Course")
.WithMany()
.HasForeignKey("CourseId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("Jiaowu.Api.Domain.Academic.ExamPlan", "ExamPlan")
.WithMany("Rooms")
.HasForeignKey("ExamPlanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Classroom");
b.Navigation("Course");
b.Navigation("ExamPlan");
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamRoomInvigilator", b =>
{
b.HasOne("Jiaowu.Api.Domain.Academic.ExamRoomAssignment", "ExamRoom")
.WithMany("Invigilators")
.HasForeignKey("ExamRoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Jiaowu.Api.Domain.Academic.Teacher", "Teacher")
.WithMany()
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("ExamRoom");
b.Navigation("Teacher");
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamRoomSession", b =>
{
b.HasOne("Jiaowu.Api.Domain.Academic.ExamRoomAssignment", "ExamRoom")
.WithMany("SessionLinks")
.HasForeignKey("ExamRoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Jiaowu.Api.Domain.Academic.ExamSession", "ExamSession")
.WithMany("RoomLinks")
.HasForeignKey("ExamSessionId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("ExamRoom");
b.Navigation("ExamSession");
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamSeatAssignment", b =>
{
b.HasOne("Jiaowu.Api.Domain.Academic.ExamRoomAssignment", "ExamRoom")
.WithMany("Seats")
.HasForeignKey("ExamRoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Jiaowu.Api.Domain.Academic.ExamSession", "ExamSession")
.WithMany("SeatAssignments")
.HasForeignKey("ExamSessionId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student")
.WithMany()
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("ExamRoom");
b.Navigation("ExamSession");
b.Navigation("Student");
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamSession", b =>
{
b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom")
@@ -4832,12 +5037,27 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamPlan", b =>
{
b.Navigation("Rooms");
b.Navigation("Sessions");
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamRoomAssignment", b =>
{
b.Navigation("Invigilators");
b.Navigation("Seats");
b.Navigation("SessionLinks");
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamSession", b =>
{
b.Navigation("Invigilators");
b.Navigation("RoomLinks");
b.Navigation("SeatAssignments");
});
modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeItem", b =>