From 18d2b45b47c7675ff2bdb0870533958112727438 Mon Sep 17 00:00:00 2001 From: biss Date: Thu, 22 Oct 2026 21:05:47 +0800 Subject: [PATCH] feat: add comprehensive assessment module --- .../Controllers/AcademicCalendarController.cs | 2 +- .../ComprehensiveAssessmentsController.cs | 664 + .../ComprehensiveAssessmentEntities.cs | 202 + .../Domain/Identity/ApplicationUser.cs | 4 +- .../System/BackgroundJobOutboxMessage.cs | 3 +- ...rehensiveAssessmentCalculationProcessor.cs | 272 + .../Auth/CurrentUserDataScope.cs | 1 + .../BackgroundJobs/BackgroundJobOptions.cs | 2 + .../BackgroundJobOutboxPublisher.cs | 11 + .../BackgroundJobs/BackgroundJobRunner.cs | 13 + .../BackgroundJobs/RabbitMqBackgroundJobs.cs | 4 +- .../Persistence/AppDbContext.cs | 123 + .../Persistence/DatabaseInitializer.cs | 3 +- ...25028_ComprehensiveAssessments.Designer.cs | 10768 ++++++++++++++++ ...20261022125028_ComprehensiveAssessments.cs | 518 + .../MySql/AppDbContextModelSnapshot.cs | 736 ++ .../Plugins/BuiltInPluginCatalog.cs | 9 + src/Jiaowu.Api/Program.cs | 2 + src/Jiaowu.Api/appsettings.json | 1 + ...ComprehensiveAssessmentsControllerTests.cs | 159 + web/src/layouts/AdminLayout.vue | 12 + web/src/router/index.ts | 6 + web/src/views/AcademicCalendarView.vue | 1 + .../views/ComprehensiveAssessmentsView.vue | 183 + 24 files changed, 13694 insertions(+), 5 deletions(-) create mode 100644 src/Jiaowu.Api/Controllers/ComprehensiveAssessmentsController.cs create mode 100644 src/Jiaowu.Api/Domain/Academic/ComprehensiveAssessmentEntities.cs create mode 100644 src/Jiaowu.Api/Infrastructure/Assessments/ComprehensiveAssessmentCalculationProcessor.cs create mode 100644 src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/20261022125028_ComprehensiveAssessments.Designer.cs create mode 100644 src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/20261022125028_ComprehensiveAssessments.cs create mode 100644 tests/Jiaowu.Api.Tests/ComprehensiveAssessmentsControllerTests.cs create mode 100644 web/src/views/ComprehensiveAssessmentsView.vue diff --git a/src/Jiaowu.Api/Controllers/AcademicCalendarController.cs b/src/Jiaowu.Api/Controllers/AcademicCalendarController.cs index a913eaf..5b5e3f3 100644 --- a/src/Jiaowu.Api/Controllers/AcademicCalendarController.cs +++ b/src/Jiaowu.Api/Controllers/AcademicCalendarController.cs @@ -146,7 +146,7 @@ public sealed class AcademicCalendarController(AppDbContext db, HolidayCnClient return null; } - private static readonly HashSet KnownRoles = [SystemRoles.SuperAdmin, SystemRoles.AcademicAdmin, SystemRoles.CollegeAdmin, SystemRoles.Leader, SystemRoles.Counselor, SystemRoles.Teacher, SystemRoles.Student, SystemRoles.MaintenanceAdmin, SystemRoles.MaintenanceStaff, SystemRoles.PhysicalEducationAdmin, SystemRoles.DormitoryAdmin]; + private static readonly HashSet KnownRoles = [SystemRoles.SuperAdmin, SystemRoles.AcademicAdmin, SystemRoles.CollegeAdmin, SystemRoles.Leader, SystemRoles.Counselor, SystemRoles.Teacher, SystemRoles.Student, SystemRoles.MaintenanceAdmin, SystemRoles.MaintenanceStaff, SystemRoles.PhysicalEducationAdmin, SystemRoles.DormitoryAdmin, SystemRoles.StudentAffairsAdmin]; private static bool IsForRoles(string? audienceRoles, HashSet roles) => string.IsNullOrWhiteSpace(audienceRoles) || audienceRoles.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Any(roles.Contains); private static string? SerializeRoles(IReadOnlyCollection roles) => roles.Count == 0 ? null : string.Join(',', roles.Distinct().Order()); private static object ToResponse(AcademicCalendarEvent item) => new { item.Id, item.AcademicTermId, AcademicTermName = item.AcademicTerm?.Name, item.Title, item.Kind, item.StartsOn, item.EndsOn, item.ReminderDays, AudienceRoles = string.IsNullOrWhiteSpace(item.AudienceRoles) ? Array.Empty() : item.AudienceRoles.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries), item.Description, item.IsEnabled, item.Source, item.SourceYear, item.IsOffDay }; diff --git a/src/Jiaowu.Api/Controllers/ComprehensiveAssessmentsController.cs b/src/Jiaowu.Api/Controllers/ComprehensiveAssessmentsController.cs new file mode 100644 index 0000000..e4a8166 --- /dev/null +++ b/src/Jiaowu.Api/Controllers/ComprehensiveAssessmentsController.cs @@ -0,0 +1,664 @@ +using System.ComponentModel.DataAnnotations; +using Jiaowu.Api.Contracts; +using Jiaowu.Api.Domain.Academic; +using Jiaowu.Api.Domain.Identity; +using Jiaowu.Api.Domain.System; +using Jiaowu.Api.Infrastructure.Auth; +using Jiaowu.Api.Infrastructure.Excel; +using Jiaowu.Api.Infrastructure.Files; +using Jiaowu.Api.Infrastructure.Persistence; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace Jiaowu.Api.Controllers; + +[ApiController] +[Authorize] +[Route("api/comprehensive-assessments")] +public sealed class ComprehensiveAssessmentsController( + AppDbContext db, + ICurrentUserDataScope currentUserDataScope) : ControllerBase +{ + private const string Managers = SystemRoles.SuperAdmin + "," + SystemRoles.AcademicAdmin + "," + SystemRoles.StudentAffairsAdmin; + private const string SchemeEditors = Managers + "," + SystemRoles.CollegeAdmin; + private const string Reviewers = SchemeEditors + "," + SystemRoles.Counselor; + private const string Readers = Reviewers + "," + SystemRoles.Leader; + + [HttpGet("schemes")] + [Authorize(Roles = SchemeEditors)] + public async Task GetSchemes(CancellationToken token) + { + var query = db.ComprehensiveAssessmentSchemes.AsNoTracking(); + var collegeId = RestrictedCollegeId(); + if (collegeId.HasValue) query = query.Where(x => x.CollegeId == collegeId || + x.CollegeId == null && x.Status == ComprehensiveAssessmentSchemeStatus.Published); + return Ok(await query.OrderByDescending(x => x.CreatedAt).Select(x => new + { + x.Id, x.Name, x.Version, x.CollegeId, CollegeName = x.College != null ? x.College.Name : "全校", + x.Status, x.RankingScope, x.PublicityDays, x.Notes, x.PublishedAt, + Dimensions = x.Dimensions.OrderBy(d => d.SortOrder).Select(d => new + { d.Id, d.Code, d.Name, d.SourceType, d.Weight, d.MaxScore, d.IsRequired, d.SortOrder }), + Rules = x.Rules.OrderBy(r => r.SortOrder).Select(r => new + { r.Id, r.ComprehensiveAssessmentDimensionId, r.Category, r.Level, r.Score, r.CategoryCap, r.SortOrder }) + }).ToListAsync(token)); + } + + [HttpPost("schemes")] + [Authorize(Roles = SchemeEditors)] + public async Task CreateScheme(ComprehensiveAssessmentSchemeRequest request, CancellationToken token) + { + var error = ValidateScheme(request); + if (error is not null) return ValidationProblem(error); + var collegeId = currentUserDataScope.Current.Scope == DataScope.College + ? currentUserDataScope.Current.CollegeId : request.CollegeId; + if (currentUserDataScope.Current.Scope == DataScope.College && !collegeId.HasValue) + return Forbid(); + + var scheme = new ComprehensiveAssessmentScheme + { + Name = request.Name.Trim(), Version = request.Version, CollegeId = collegeId, + RankingScope = request.RankingScope, PublicityDays = request.PublicityDays, + Notes = request.Notes?.Trim(), CreatedByUserId = currentUserDataScope.Current.UserId + }; + foreach (var input in request.Dimensions.OrderBy(x => x.SortOrder)) + scheme.Dimensions.Add(new ComprehensiveAssessmentDimension + { + Code = input.Code.Trim(), Name = input.Name.Trim(), SourceType = input.SourceType, + Weight = input.Weight, MaxScore = input.MaxScore, SortOrder = input.SortOrder, + IsRequired = input.IsRequired, SettingsJson = input.SettingsJson + }); + foreach (var input in request.Rules.OrderBy(x => x.SortOrder)) + { + var dimension = scheme.Dimensions.FirstOrDefault(x => x.Code.Equals(input.DimensionCode.Trim(), StringComparison.OrdinalIgnoreCase)); + if (dimension is null || dimension.SourceType != ComprehensiveAssessmentSourceType.Declaration) + return ValidationProblem($"加扣分规则 {input.Category}/{input.Level} 未关联材料申报维度。"); + scheme.Rules.Add(new ComprehensiveAssessmentRule + { + Dimension = dimension, Category = input.Category.Trim(), Level = input.Level.Trim(), + Score = input.Score, CategoryCap = input.CategoryCap, SortOrder = input.SortOrder + }); + } + db.ComprehensiveAssessmentSchemes.Add(scheme); + await db.SaveChangesAsync(token); + return Created(string.Empty, new { scheme.Id }); + } + + [HttpPost("schemes/{id:guid}/publish")] + [Authorize(Roles = SchemeEditors)] + public async Task PublishScheme(Guid id, CancellationToken token) + { + var scheme = await EditableSchemes().FirstOrDefaultAsync(x => x.Id == id, token); + if (scheme is null) return NotFound(); + if (scheme.Status != ComprehensiveAssessmentSchemeStatus.Draft) return ConflictProblem("只有草稿方案可以发布。"); + scheme.Status = ComprehensiveAssessmentSchemeStatus.Published; + scheme.PublishedAt = DateTime.UtcNow; + await db.SaveChangesAsync(token); + return NoContent(); + } + + [HttpPut("schemes/{id:guid}")] + [Authorize(Roles = SchemeEditors)] + public async Task UpdateScheme(Guid id, ComprehensiveAssessmentSchemeRequest request, CancellationToken token) + { + var error = ValidateScheme(request); + if (error is not null) return ValidationProblem(error); + var scheme = await EditableSchemes().Include(x => x.Dimensions).Include(x => x.Rules) + .FirstOrDefaultAsync(x => x.Id == id, token); + if (scheme is null) return NotFound(); + if (scheme.Status != ComprehensiveAssessmentSchemeStatus.Draft) return ConflictProblem("已发布方案不能原地修改,请新建版本。"); + + await using var transaction = await db.Database.BeginTransactionAsync(token); + db.ComprehensiveAssessmentRules.RemoveRange(scheme.Rules); + db.ComprehensiveAssessmentDimensions.RemoveRange(scheme.Dimensions); + await db.SaveChangesAsync(token); + scheme.Rules.Clear(); + scheme.Dimensions.Clear(); + scheme.Name = request.Name.Trim(); scheme.Version = request.Version; + scheme.RankingScope = request.RankingScope; scheme.PublicityDays = request.PublicityDays; + scheme.Notes = request.Notes?.Trim(); + if (currentUserDataScope.Current.Scope != DataScope.College) scheme.CollegeId = request.CollegeId; + foreach (var input in request.Dimensions.OrderBy(x => x.SortOrder)) + scheme.Dimensions.Add(new ComprehensiveAssessmentDimension + { + Code = input.Code.Trim(), Name = input.Name.Trim(), SourceType = input.SourceType, + Weight = input.Weight, MaxScore = input.MaxScore, SortOrder = input.SortOrder, + IsRequired = input.IsRequired, SettingsJson = input.SettingsJson + }); + foreach (var input in request.Rules.OrderBy(x => x.SortOrder)) + { + var dimension = scheme.Dimensions.FirstOrDefault(x => x.Code.Equals(input.DimensionCode.Trim(), StringComparison.OrdinalIgnoreCase)); + if (dimension is null || dimension.SourceType != ComprehensiveAssessmentSourceType.Declaration) + return ValidationProblem($"加扣分规则 {input.Category}/{input.Level} 未关联材料申报维度。"); + scheme.Rules.Add(new ComprehensiveAssessmentRule + { + Dimension = dimension, Category = input.Category.Trim(), Level = input.Level.Trim(), + Score = input.Score, CategoryCap = input.CategoryCap, SortOrder = input.SortOrder + }); + } + await db.SaveChangesAsync(token); + await transaction.CommitAsync(token); + return NoContent(); + } + + [HttpGet("batches")] + [Authorize(Roles = Readers + "," + SystemRoles.Student)] + public async Task GetBatches(CancellationToken token) + { + var studentId = currentUserDataScope.Current.Scope == DataScope.Self ? await CurrentStudentIdAsync(token) : null; + var query = db.ComprehensiveAssessmentBatches.AsNoTracking(); + if (studentId.HasValue) + { + var collegeId = await db.Students.Where(x => x.Id == studentId).Select(x => x.AdministrativeClass!.Major!.CollegeId).FirstAsync(token); + query = query.Where(x => (x.CollegeId == null || x.CollegeId == collegeId) && + (x.Status == ComprehensiveAssessmentBatchStatus.Collecting || + x.Status == ComprehensiveAssessmentBatchStatus.Publicizing || + x.Status == ComprehensiveAssessmentBatchStatus.Published)); + } + else query = ApplyBatchScope(query); + return Ok(await query.OrderByDescending(x => x.CreatedAt).Select(x => new + { + x.Id, x.Name, x.AcademicYear, x.AcademicTermId, TermName = x.AcademicTerm != null ? x.AcademicTerm.Name : null, + x.CollegeId, CollegeName = x.College != null ? x.College.Name : "全校", x.Status, + x.CalculationStatus, x.CalculationError, x.CalculatedAt, x.PublicityStartsAt, + x.PublicityEndsAt, x.PublishedAt, x.PublicationCount, x.Notes, + SchemeName = x.Scheme!.Name, SchemeVersion = x.Scheme.Version, + ResultCount = x.Results.Count, DeclarationCount = x.Declarations.Count, + Dimensions = x.Scheme.Dimensions.OrderBy(d => d.SortOrder).Select(d => new + { d.Id, d.Name, d.SourceType, d.Weight, d.MaxScore, d.IsRequired }), + Rules = x.Scheme.Rules.OrderBy(r => r.SortOrder).Select(r => new + { r.Id, r.ComprehensiveAssessmentDimensionId, DimensionName = r.Dimension!.Name, + r.Category, r.Level, r.Score, r.CategoryCap }) + }).ToListAsync(token)); + } + + [HttpPost("batches")] + [Authorize(Roles = SchemeEditors)] + public async Task CreateBatch(ComprehensiveAssessmentBatchRequest request, CancellationToken token) + { + var scheme = await ScopedSchemes().AsNoTracking().FirstOrDefaultAsync(x => x.Id == request.SchemeId, token); + if (scheme is null) return NotFound("测评方案不存在或不在权限范围内。"); + if (scheme.Status != ComprehensiveAssessmentSchemeStatus.Published) return ConflictProblem("只能使用已发布的测评方案。"); + var collegeId = currentUserDataScope.Current.Scope == DataScope.College + ? currentUserDataScope.Current.CollegeId : request.CollegeId ?? scheme.CollegeId; + if (scheme.CollegeId.HasValue && collegeId != scheme.CollegeId) return ValidationProblem("批次学院必须与方案适用学院一致。"); + if (request.AcademicTermId.HasValue && !await db.AcademicTerms.AnyAsync(x => x.Id == request.AcademicTermId, token)) + return ValidationProblem("学期不存在。"); + var batch = new ComprehensiveAssessmentBatch + { + ComprehensiveAssessmentSchemeId = scheme.Id, Name = request.Name.Trim(), + AcademicYear = request.AcademicYear.Trim(), AcademicTermId = request.AcademicTermId, + CollegeId = collegeId, Notes = request.Notes?.Trim(), CreatedByUserId = currentUserDataScope.Current.UserId + }; + db.ComprehensiveAssessmentBatches.Add(batch); + await db.SaveChangesAsync(token); + return Created(string.Empty, new { batch.Id }); + } + + [HttpPost("batches/{id:guid}/status")] + [Authorize(Roles = SchemeEditors)] + public async Task ChangeBatchStatus(Guid id, ChangeAssessmentBatchStatusRequest request, CancellationToken token) + { + var batch = await EditableBatches().FirstOrDefaultAsync(x => x.Id == id, token); + if (batch is null) return NotFound(); + var allowed = batch.Status switch + { + ComprehensiveAssessmentBatchStatus.Draft => request.Status == ComprehensiveAssessmentBatchStatus.Collecting, + ComprehensiveAssessmentBatchStatus.Collecting => request.Status == ComprehensiveAssessmentBatchStatus.Reviewing, + _ => false + }; + if (!allowed) return ConflictProblem("批次状态不能按该路径变更。"); + batch.Status = request.Status; + await db.SaveChangesAsync(token); + return NoContent(); + } + + [HttpPost("batches/{id:guid}/calculate")] + [Authorize(Roles = SchemeEditors)] + public async Task QueueCalculation(Guid id, CancellationToken token) + { + var batch = await EditableBatches().FirstOrDefaultAsync(x => x.Id == id, token); + if (batch is null) return NotFound(); + if (batch.Status is ComprehensiveAssessmentBatchStatus.Draft or ComprehensiveAssessmentBatchStatus.Collecting) + return ConflictProblem("请先结束采集并进入审核阶段。"); + if (batch.CalculationStatus is ComprehensiveAssessmentCalculationStatus.Queued or ComprehensiveAssessmentCalculationStatus.Running) + return ConflictProblem("该批次正在后台计算。"); + batch.CalculationStatus = ComprehensiveAssessmentCalculationStatus.Queued; + batch.CalculationError = null; + var outbox = await db.BackgroundJobOutboxMessages.FirstOrDefaultAsync(x => + x.JobKind == BackgroundJobKind.ComprehensiveAssessmentCalculation && x.JobId == id, token); + if (outbox is null) + db.BackgroundJobOutboxMessages.Add(BackgroundJobOutboxMessage.Create(BackgroundJobKind.ComprehensiveAssessmentCalculation, id)); + else + { + outbox.State = BackgroundJobOutboxState.Pending; outbox.CompletedAt = null; + outbox.ProcessingToken = null; outbox.LeaseExpiresAt = null; outbox.LastError = null; + } + await db.SaveChangesAsync(token); + return Accepted(new { batch.Id, batch.CalculationStatus }); + } + + [HttpPost("batches/{id:guid}/publicize")] + [Authorize(Roles = SchemeEditors)] + public async Task Publicize(Guid id, PublicationRequest request, CancellationToken token) + { + var batch = await EditableBatches().Include(x => x.Scheme).Include(x => x.Publications).FirstOrDefaultAsync(x => x.Id == id, token); + if (batch is null) return NotFound(); + if (batch.CalculationStatus != ComprehensiveAssessmentCalculationStatus.Succeeded) + return ConflictProblem("测评结果尚未计算完成。"); + if (batch.Status is not (ComprehensiveAssessmentBatchStatus.Reviewing or ComprehensiveAssessmentBatchStatus.Publicizing or ComprehensiveAssessmentBatchStatus.Published)) + return ConflictProblem("当前批次不能进入公示。"); + var now = DateTime.UtcNow; + batch.Status = ComprehensiveAssessmentBatchStatus.Publicizing; + batch.PublicityStartsAt = now; + batch.PublicityEndsAt = now.AddDays(batch.Scheme!.PublicityDays); + AddPublication(batch, ComprehensiveAssessmentPublicationType.Publicity, request.Note, now); + await db.SaveChangesAsync(token); + return NoContent(); + } + + [HttpPost("batches/{id:guid}/publish")] + [Authorize(Roles = Managers)] + public async Task Publish(Guid id, PublicationRequest request, CancellationToken token) + { + var batch = await db.ComprehensiveAssessmentBatches.Include(x => x.Publications).FirstOrDefaultAsync(x => x.Id == id, token); + if (batch is null) return NotFound(); + if (batch.Status != ComprehensiveAssessmentBatchStatus.Publicizing) return ConflictProblem("批次尚未进入公示。"); + if (batch.PublicityEndsAt > DateTime.UtcNow && !request.Force) + return ConflictProblem("公示期尚未结束。如确需提前发布,必须明确确认强制发布。"); + if (await db.ComprehensiveAssessmentAppeals.AnyAsync(x => x.ComprehensiveAssessmentBatchId == id && x.Status == ComprehensiveAssessmentAppealStatus.Submitted, token)) + return ConflictProblem("仍有待处理申诉,不能正式发布。"); + var now = DateTime.UtcNow; + var isRevision = batch.PublicationCount > 0; + batch.Status = ComprehensiveAssessmentBatchStatus.Published; + batch.PublishedAt = now; + batch.PublicationCount++; + AddPublication(batch, isRevision ? ComprehensiveAssessmentPublicationType.Revision : ComprehensiveAssessmentPublicationType.Final, request.Note, now); + await db.SaveChangesAsync(token); + return NoContent(); + } + + [HttpGet("batches/{id:guid}/results")] + [Authorize(Roles = Readers)] + public async Task GetResults(Guid id, int page = 1, int pageSize = 30, string? keyword = null, CancellationToken token = default) + { + if (!await ApplyBatchScope(db.ComprehensiveAssessmentBatches.AsNoTracking()).AnyAsync(x => x.Id == id, token)) return NotFound(); + page = Math.Max(page, 1); pageSize = Math.Clamp(pageSize, 10, 100); + var query = ApplyResultScope(db.ComprehensiveAssessmentResults.AsNoTracking()).Where(x => x.ComprehensiveAssessmentBatchId == id); + if (!string.IsNullOrWhiteSpace(keyword)) + { + var value = keyword.Trim(); + query = query.Where(x => x.Student!.StudentNumber.Contains(value) || x.Student.Name.Contains(value) || x.Student.AdministrativeClass!.Name.Contains(value)); + } + var total = await query.CountAsync(token); + var items = await query.OrderBy(x => x.ClassRank).ThenBy(x => x.Student!.StudentNumber) + .Skip((page - 1) * pageSize).Take(pageSize).Select(x => new + { + x.Id, x.StudentId, x.Student!.StudentNumber, x.Student.Name, + ClassName = x.Student.AdministrativeClass!.Name, MajorName = x.Student.AdministrativeClass.Major!.Name, + CollegeName = x.Student.AdministrativeClass.Major.College!.Name, + x.TotalScore, x.ClassRank, x.MajorRank, x.CollegeRank, x.MissingRequiredDimensionCount, + Details = x.Details.OrderBy(d => d.Dimension!.SortOrder).Select(d => new + { d.Id, d.ComprehensiveAssessmentDimensionId, d.Dimension!.Name, d.Dimension.SourceType, + d.SourceStatus, d.RawScore, d.WeightedScore, d.Explanation }) + }).ToListAsync(token); + return Ok(new { Items = items, Total = total, Page = page, PageSize = pageSize }); + } + + [HttpGet("batches/{id:guid}/export.xlsx")] + [Authorize(Roles = Readers)] + public async Task ExportResults(Guid id, CancellationToken token) + { + var batch = await ApplyBatchScope(db.ComprehensiveAssessmentBatches.AsNoTracking()) + .Include(x => x.Scheme).ThenInclude(x => x!.Dimensions) + .FirstOrDefaultAsync(x => x.Id == id, token); + if (batch is null) return NotFound(); + var dimensions = batch.Scheme!.Dimensions.OrderBy(x => x.SortOrder).ToArray(); + var results = await ApplyResultScope(db.ComprehensiveAssessmentResults.AsNoTracking()) + .Where(x => x.ComprehensiveAssessmentBatchId == id) + .Include(x => x.Details) + .Include(x => x.Student).ThenInclude(x => x!.AdministrativeClass).ThenInclude(x => x!.Major).ThenInclude(x => x!.College) + .OrderBy(x => x.Student!.AdministrativeClass!.Code).ThenBy(x => x.ClassRank).ThenBy(x => x.Student!.StudentNumber) + .ToListAsync(token); + var headers = new List { "学号", "姓名", "行政班", "专业", "学院", "总分", "班级排名", "专业排名", "学院排名", "缺失必需维度数" }; + headers.AddRange(dimensions.Select(x => $"{x.Name}原始分")); + headers.AddRange(dimensions.Select(x => $"{x.Name}折算分")); + var rows = results.Select(result => + { + var values = new List + { + result.Student!.StudentNumber, result.Student.Name, result.Student.AdministrativeClass!.Name, + result.Student.AdministrativeClass.Major!.Name, result.Student.AdministrativeClass.Major.College!.Name, + result.TotalScore, result.ClassRank, result.MajorRank, result.CollegeRank, result.MissingRequiredDimensionCount + }; + var detailMap = result.Details.ToDictionary(x => x.ComprehensiveAssessmentDimensionId); + values.AddRange(dimensions.Select(x => detailMap.GetValueOrDefault(x.Id)?.RawScore)); + values.AddRange(dimensions.Select(x => detailMap.GetValueOrDefault(x.Id)?.WeightedScore)); + return (IReadOnlyList)values; + }).ToList(); + var bytes = ExcelWorkbookHelper.Create("综合测评结果", headers, rows, + ["导出内容只包含当前账号数据权限范围内的学生。", "原始分、折算分及排名均来自本批次最后一次成功计算快照。"]); + return File(bytes, ExcelWorkbookHelper.ContentType, + DownloadFileName.Export("综合测评结果", ".xlsx", batch.Name)); + } + + [HttpGet("mine")] + [Authorize(Roles = SystemRoles.Student)] + public async Task Mine(CancellationToken token) + { + var studentId = await RequireCurrentStudentIdAsync(token); + if (!studentId.HasValue) return NotFound("当前账号未关联学生档案。"); + var results = await db.ComprehensiveAssessmentResults.AsNoTracking() + .Where(x => x.StudentId == studentId && (x.Batch!.Status == ComprehensiveAssessmentBatchStatus.Publicizing || x.Batch!.Status == ComprehensiveAssessmentBatchStatus.Published)) + .OrderByDescending(x => x.Batch!.AcademicYear).ThenByDescending(x => x.Batch!.CreatedAt) + .Select(x => new + { + x.Id, BatchId = x.ComprehensiveAssessmentBatchId, BatchName = x.Batch!.Name, x.Batch.AcademicYear, + x.Batch.Status, x.Batch.PublicityStartsAt, x.Batch.PublicityEndsAt, x.Batch.PublishedAt, + x.TotalScore, x.ClassRank, x.MajorRank, x.CollegeRank, x.MissingRequiredDimensionCount, + Details = x.Details.OrderBy(d => d.Dimension!.SortOrder).Select(d => new + { d.Id, d.Dimension!.Name, d.Dimension.SourceType, d.Dimension.Weight, d.SourceStatus, d.RawScore, d.WeightedScore, d.Explanation }) + }).ToListAsync(token); + return Ok(results); + } + + [HttpGet("declarations/mine")] + [Authorize(Roles = SystemRoles.Student)] + public async Task MyDeclarations(CancellationToken token) + { + var studentId = await RequireCurrentStudentIdAsync(token); + if (!studentId.HasValue) return NotFound(); + var query = db.ComprehensiveAssessmentDeclarations.AsNoTracking() + .Where(x => x.StudentId == studentId).OrderByDescending(x => x.CreatedAt); + return Ok(await DeclarationProjection(query).ToListAsync(token)); + } + + [HttpPost("declarations")] + [Authorize(Roles = SystemRoles.Student)] + public async Task CreateDeclaration(ComprehensiveAssessmentDeclarationRequest request, CancellationToken token) + { + var studentId = await RequireCurrentStudentIdAsync(token); + if (!studentId.HasValue) return NotFound(); + var rule = await db.ComprehensiveAssessmentRules.AsNoTracking().Include(x => x.Dimension).Include(x => x.Scheme) + .FirstOrDefaultAsync(x => x.Id == request.RuleId, token); + var batch = await db.ComprehensiveAssessmentBatches.FirstOrDefaultAsync(x => x.Id == request.BatchId, token); + if (batch is null || rule is null || rule.ComprehensiveAssessmentSchemeId != batch.ComprehensiveAssessmentSchemeId) + return ValidationProblem("批次或加分规则无效。"); + if (batch.Status != ComprehensiveAssessmentBatchStatus.Collecting) return ConflictProblem("当前批次不在材料采集期。"); + if (!await StudentBelongsToBatch(studentId.Value, batch, token)) return Forbid(); + if (await db.ComprehensiveAssessmentDeclarations.AnyAsync(x => + x.ComprehensiveAssessmentBatchId == batch.Id && x.StudentId == studentId && + x.ComprehensiveAssessmentRuleId == rule.Id && x.Title == request.Title.Trim() && + x.OccurredOn == request.OccurredOn && + x.Status != ComprehensiveAssessmentDeclarationStatus.Rejected && + x.Status != ComprehensiveAssessmentDeclarationStatus.Withdrawn, token)) + return ConflictProblem("同一批次中已存在相同项目、规则和日期的申报材料。"); + var declaration = new ComprehensiveAssessmentDeclaration + { + ComprehensiveAssessmentBatchId = batch.Id, StudentId = studentId.Value, + ComprehensiveAssessmentDimensionId = rule.ComprehensiveAssessmentDimensionId, + ComprehensiveAssessmentRuleId = rule.Id, Title = request.Title.Trim(), Category = rule.Category, + Level = rule.Level, OccurredOn = request.OccurredOn, EvidenceDescription = request.EvidenceDescription?.Trim(), + EvidenceUrl = request.EvidenceUrl?.Trim(), ClaimedScore = rule.Score + }; + db.ComprehensiveAssessmentDeclarations.Add(declaration); + await db.SaveChangesAsync(token); + return Created(string.Empty, new { declaration.Id }); + } + + [HttpPost("declarations/{id:guid}/submit")] + [Authorize(Roles = SystemRoles.Student)] + public async Task SubmitDeclaration(Guid id, CancellationToken token) + { + var studentId = await RequireCurrentStudentIdAsync(token); + var item = await db.ComprehensiveAssessmentDeclarations.Include(x => x.Batch) + .FirstOrDefaultAsync(x => x.Id == id && x.StudentId == studentId, token); + if (item is null) return NotFound(); + if (item.Batch!.Status != ComprehensiveAssessmentBatchStatus.Collecting || item.Status != ComprehensiveAssessmentDeclarationStatus.Draft) + return ConflictProblem("该材料当前不能提交。"); + item.Status = ComprehensiveAssessmentDeclarationStatus.Submitted; + item.SubmittedAt = DateTime.UtcNow; + await db.SaveChangesAsync(token); + return NoContent(); + } + + [HttpGet("declarations/pending")] + [Authorize(Roles = Reviewers)] + public async Task PendingDeclarations(CancellationToken token) + { + var query = ApplyDeclarationScope(db.ComprehensiveAssessmentDeclarations.AsNoTracking()) + .Where(x => x.Status == ComprehensiveAssessmentDeclarationStatus.Submitted || x.Status == ComprehensiveAssessmentDeclarationStatus.CounselorApproved); + return Ok(await DeclarationProjection(query.OrderBy(x => x.SubmittedAt)).ToListAsync(token)); + } + + [HttpPost("declarations/{id:guid}/review")] + [Authorize(Roles = Reviewers)] + public async Task ReviewDeclaration(Guid id, ReviewAssessmentDeclarationRequest request, CancellationToken token) + { + var item = await ApplyDeclarationScope(db.ComprehensiveAssessmentDeclarations).Include(x => x.Dimension).FirstOrDefaultAsync(x => x.Id == id, token); + if (item is null) return NotFound(); + var current = currentUserDataScope.Current; + var counselorStage = current.Scope == DataScope.Class && current.IsInRole(SystemRoles.Counselor); + if (counselorStage) + { + if (item.Status != ComprehensiveAssessmentDeclarationStatus.Submitted) return ConflictProblem("材料不在辅导员初审阶段。"); + item.CounselorReviewedByUserId = current.UserId; item.CounselorReviewedAt = DateTime.UtcNow; + item.CounselorComment = request.Comment?.Trim(); + item.Status = request.Approved ? ComprehensiveAssessmentDeclarationStatus.CounselorApproved : ComprehensiveAssessmentDeclarationStatus.Rejected; + } + else + { + if (item.Status is not (ComprehensiveAssessmentDeclarationStatus.Submitted or ComprehensiveAssessmentDeclarationStatus.CounselorApproved)) + return ConflictProblem("材料不在学院复核阶段。"); + if (!request.Approved && string.IsNullOrWhiteSpace(request.Comment)) return ValidationProblem("驳回时必须填写审核意见。"); + if (request.Approved && request.ApprovedScore.HasValue && + Math.Abs(request.ApprovedScore.Value) > item.Dimension!.MaxScore) + return ValidationProblem("复核分值不能超过所属维度满分的绝对值。"); + item.CollegeReviewedByUserId = current.UserId; item.CollegeReviewedAt = DateTime.UtcNow; + item.CollegeComment = request.Comment?.Trim(); item.ApprovedScore = request.Approved ? request.ApprovedScore ?? item.ClaimedScore : null; + item.Status = request.Approved ? ComprehensiveAssessmentDeclarationStatus.Approved : ComprehensiveAssessmentDeclarationStatus.Rejected; + } + await db.SaveChangesAsync(token); + return NoContent(); + } + + [HttpPost("appeals")] + [Authorize(Roles = SystemRoles.Student)] + public async Task CreateAppeal(ComprehensiveAssessmentAppealRequest request, CancellationToken token) + { + var studentId = await RequireCurrentStudentIdAsync(token); + if (!studentId.HasValue) return NotFound(); + var batch = await db.ComprehensiveAssessmentBatches.AsNoTracking().FirstOrDefaultAsync(x => x.Id == request.BatchId, token); + if (batch is null || batch.Status != ComprehensiveAssessmentBatchStatus.Publicizing || batch.PublicityEndsAt < DateTime.UtcNow) + return ConflictProblem("当前不在结果公示申诉期。"); + if (!await db.ComprehensiveAssessmentResults.AnyAsync(x => x.ComprehensiveAssessmentBatchId == batch.Id && x.StudentId == studentId, token)) + return Forbid(); + if (request.ResultDetailId.HasValue && !await db.ComprehensiveAssessmentResultDetails.AnyAsync(x => + x.Id == request.ResultDetailId && x.Result!.ComprehensiveAssessmentBatchId == batch.Id && + x.Result.StudentId == studentId, token)) + return ValidationProblem("申诉明细不属于当前学生的本批次结果。"); + if (await db.ComprehensiveAssessmentAppeals.AnyAsync(x => x.ComprehensiveAssessmentBatchId == batch.Id && x.StudentId == studentId && x.Status == ComprehensiveAssessmentAppealStatus.Submitted, token)) + return ConflictProblem("该批次已有待处理申诉。"); + var appeal = new ComprehensiveAssessmentAppeal + { + ComprehensiveAssessmentBatchId = batch.Id, StudentId = studentId.Value, + ComprehensiveAssessmentResultDetailId = request.ResultDetailId, Reason = request.Reason.Trim() + }; + db.ComprehensiveAssessmentAppeals.Add(appeal); + await db.SaveChangesAsync(token); + return Created(string.Empty, new { appeal.Id }); + } + + [HttpGet("appeals")] + [Authorize(Roles = Reviewers + "," + SystemRoles.Student)] + public async Task GetAppeals(CancellationToken token) + { + var studentId = currentUserDataScope.Current.Scope == DataScope.Self ? await CurrentStudentIdAsync(token) : null; + var query = db.ComprehensiveAssessmentAppeals.AsNoTracking(); + query = studentId.HasValue ? query.Where(x => x.StudentId == studentId) : ApplyAppealScope(query); + return Ok(await query.OrderByDescending(x => x.CreatedAt).Select(x => new + { + x.Id, x.ComprehensiveAssessmentBatchId, BatchName = x.Batch!.Name, x.StudentId, + x.Student!.StudentNumber, x.Student.Name, ClassName = x.Student.AdministrativeClass!.Name, + x.ComprehensiveAssessmentResultDetailId, DimensionName = x.ResultDetail != null ? x.ResultDetail.Dimension!.Name : null, + x.Reason, x.Status, x.ReviewComment, x.ReviewedAt, x.CreatedAt + }).ToListAsync(token)); + } + + [HttpPost("appeals/{id:guid}/review")] + [Authorize(Roles = SchemeEditors)] + public async Task ReviewAppeal(Guid id, ReviewAssessmentAppealRequest request, CancellationToken token) + { + var item = await ApplyAppealScope(db.ComprehensiveAssessmentAppeals).FirstOrDefaultAsync(x => x.Id == id, token); + if (item is null) return NotFound(); + if (item.Status != ComprehensiveAssessmentAppealStatus.Submitted) return ConflictProblem("申诉已经处理。"); + item.Status = request.Approved ? ComprehensiveAssessmentAppealStatus.Approved : ComprehensiveAssessmentAppealStatus.Rejected; + item.ReviewComment = request.Comment.Trim(); item.ReviewedByUserId = currentUserDataScope.Current.UserId; item.ReviewedAt = DateTime.UtcNow; + await db.SaveChangesAsync(token); + return NoContent(); + } + + private IQueryable ScopedSchemes() + { + var query = db.ComprehensiveAssessmentSchemes.AsQueryable(); + var collegeId = RestrictedCollegeId(); + return collegeId.HasValue ? query.Where(x => x.CollegeId == null || x.CollegeId == collegeId) : query; + } + + private IQueryable ScopedBatches() => ApplyBatchScope(db.ComprehensiveAssessmentBatches); + private IQueryable EditableSchemes() + { + var current = currentUserDataScope.Current; + return current.Scope == DataScope.College + ? db.ComprehensiveAssessmentSchemes.Where(x => x.CollegeId == current.CollegeId) + : db.ComprehensiveAssessmentSchemes; + } + + private IQueryable EditableBatches() + { + var current = currentUserDataScope.Current; + return current.Scope == DataScope.College + ? db.ComprehensiveAssessmentBatches.Where(x => x.CollegeId == current.CollegeId) + : db.ComprehensiveAssessmentBatches; + } + + private IQueryable ApplyBatchScope(IQueryable query) + { + var current = currentUserDataScope.Current; + if (current.Scope == DataScope.College) return query.Where(x => x.CollegeId == null || x.CollegeId == current.CollegeId); + if (current.Scope == DataScope.Class) return query.Where(x => x.CollegeId == null || x.CollegeId == current.CollegeId); + return query; + } + + private IQueryable ApplyResultScope(IQueryable query) + { + var current = currentUserDataScope.Current; + if (current.Scope == DataScope.College) return query.Where(x => x.Student!.AdministrativeClass!.Major!.CollegeId == current.CollegeId); + if (current.Scope == DataScope.Class) return query.Where(x => x.Student!.AdministrativeClass!.CounselorUserId == current.UserId); + return query; + } + + private IQueryable ApplyDeclarationScope(IQueryable query) + { + var current = currentUserDataScope.Current; + if (current.Scope == DataScope.College) return query.Where(x => x.Student!.AdministrativeClass!.Major!.CollegeId == current.CollegeId); + if (current.Scope == DataScope.Class) return query.Where(x => x.Student!.AdministrativeClass!.CounselorUserId == current.UserId); + return query; + } + + private IQueryable ApplyAppealScope(IQueryable query) + { + var current = currentUserDataScope.Current; + if (current.Scope == DataScope.College) return query.Where(x => x.Student!.AdministrativeClass!.Major!.CollegeId == current.CollegeId); + if (current.Scope == DataScope.Class) return query.Where(x => x.Student!.AdministrativeClass!.CounselorUserId == current.UserId); + return query; + } + + private Guid? RestrictedCollegeId() => currentUserDataScope.Current.Scope == DataScope.College + ? currentUserDataScope.Current.CollegeId ?? Guid.Empty : null; + + private async Task CurrentStudentIdAsync(CancellationToken token) + { + if (!currentUserDataScope.Current.IsInRole(SystemRoles.Student)) return null; + return await db.Students.AsNoTracking().Where(x => x.UserId == currentUserDataScope.Current.UserId).Select(x => (Guid?)x.Id).FirstOrDefaultAsync(token); + } + private Task RequireCurrentStudentIdAsync(CancellationToken token) => CurrentStudentIdAsync(token); + + private async Task StudentBelongsToBatch(Guid studentId, ComprehensiveAssessmentBatch batch, CancellationToken token) => + await db.Students.AsNoTracking().AnyAsync(x => x.Id == studentId && + (!batch.CollegeId.HasValue || x.AdministrativeClass!.Major!.CollegeId == batch.CollegeId), token); + + private static IQueryable DeclarationProjection(IQueryable query) => + query.Select(x => new AssessmentDeclarationView( + x.Id, x.ComprehensiveAssessmentBatchId, x.Batch!.Name, x.StudentId, + x.Student!.StudentNumber, x.Student.Name, x.Student.AdministrativeClass!.Name, + x.ComprehensiveAssessmentDimensionId, x.Dimension!.Name, x.ComprehensiveAssessmentRuleId, + x.Title, x.Category, x.Level, x.OccurredOn, x.EvidenceDescription, x.EvidenceUrl, + x.ClaimedScore, x.ApprovedScore, x.Status, x.SubmittedAt, x.CounselorComment, x.CollegeComment, x.CreatedAt)); + + private void AddPublication(ComprehensiveAssessmentBatch batch, ComprehensiveAssessmentPublicationType type, string? note, DateTime now) => + batch.Publications.Add(new ComprehensiveAssessmentPublication + { + Version = batch.Publications.Count + 1, Type = type, + PublishedByUserId = currentUserDataScope.Current.UserId, PublishedAt = now, Note = note?.Trim() + }); + + private ActionResult ConflictProblem(string detail) => Conflict(new ProblemDetails + { + Status = StatusCodes.Status409Conflict, + Title = "无法完成", + Detail = detail + }); + + private static string? ValidateScheme(ComprehensiveAssessmentSchemeRequest request) + { + if (string.IsNullOrWhiteSpace(request.Name)) return "方案名称不能为空。"; + if (request.Version < 1) return "方案版本必须大于 0。"; + if (request.PublicityDays is < 1 or > 30) return "公示天数必须为 1 至 30 天。"; + if (request.Dimensions.Count == 0) return "至少需要一个测评维度。"; + if (request.Dimensions.Sum(x => x.Weight) != 100) return "维度权重之和必须为 100%。"; + if (request.Dimensions.Any(x => string.IsNullOrWhiteSpace(x.Code) || string.IsNullOrWhiteSpace(x.Name) || x.Weight < 0 || x.MaxScore <= 0)) + return "维度编码、名称、权重或满分设置无效。"; + if (request.Dimensions.Select(x => x.Code.Trim()).Distinct(StringComparer.OrdinalIgnoreCase).Count() != request.Dimensions.Count) + return "维度编码不能重复。"; + var declarationCodes = request.Dimensions + .Where(x => x.SourceType == ComprehensiveAssessmentSourceType.Declaration) + .Select(x => x.Code.Trim()).ToHashSet(StringComparer.OrdinalIgnoreCase); + if (request.Rules.Any(x => string.IsNullOrWhiteSpace(x.Category) || string.IsNullOrWhiteSpace(x.Level) || + !declarationCodes.Contains(x.DimensionCode.Trim()))) + return "每条加扣分规则都必须关联有效的材料申报维度,并填写类别和级别。"; + return null; + } +} + +public sealed record ComprehensiveAssessmentSchemeRequest( + [Required, MaxLength(150)] string Name, int Version, Guid? CollegeId, + ComprehensiveAssessmentRankingScope RankingScope, int PublicityDays, + [MaxLength(1000)] string? Notes, + [Required] IReadOnlyList Dimensions, + [Required] IReadOnlyList Rules); +public sealed record ComprehensiveAssessmentDimensionRequest( + [Required, MaxLength(50)] string Code, [Required, MaxLength(100)] string Name, + ComprehensiveAssessmentSourceType SourceType, decimal Weight, decimal MaxScore, + int SortOrder, bool IsRequired, string? SettingsJson); +public sealed record ComprehensiveAssessmentRuleRequest( + [Required] string DimensionCode, [Required, MaxLength(100)] string Category, + [Required, MaxLength(100)] string Level, decimal Score, decimal? CategoryCap, int SortOrder); +public sealed record ComprehensiveAssessmentBatchRequest( + Guid SchemeId, [Required, MaxLength(150)] string Name, [Required, MaxLength(20)] string AcademicYear, + Guid? AcademicTermId, Guid? CollegeId, [MaxLength(1000)] string? Notes); +public sealed record ChangeAssessmentBatchStatusRequest(ComprehensiveAssessmentBatchStatus Status); +public sealed record PublicationRequest([MaxLength(500)] string? Note, bool Force = false); +public sealed record ComprehensiveAssessmentDeclarationRequest( + Guid BatchId, Guid RuleId, [Required, MaxLength(200)] string Title, DateOnly OccurredOn, + [MaxLength(1000)] string? EvidenceDescription, [MaxLength(500)] string? EvidenceUrl); +public sealed record ReviewAssessmentDeclarationRequest(bool Approved, decimal? ApprovedScore, [MaxLength(500)] string? Comment); +public sealed record ComprehensiveAssessmentAppealRequest(Guid BatchId, Guid? ResultDetailId, [Required, MaxLength(1000)] string Reason); +public sealed record ReviewAssessmentAppealRequest(bool Approved, [Required, MaxLength(500)] string Comment); +public sealed record AssessmentDeclarationView( + Guid Id, Guid ComprehensiveAssessmentBatchId, string BatchName, Guid StudentId, + string StudentNumber, string Name, string ClassName, Guid ComprehensiveAssessmentDimensionId, + string DimensionName, Guid? ComprehensiveAssessmentRuleId, string Title, string Category, + string Level, DateOnly OccurredOn, string? EvidenceDescription, string? EvidenceUrl, + decimal ClaimedScore, decimal? ApprovedScore, ComprehensiveAssessmentDeclarationStatus Status, + DateTime? SubmittedAt, string? CounselorComment, string? CollegeComment, DateTime CreatedAt); diff --git a/src/Jiaowu.Api/Domain/Academic/ComprehensiveAssessmentEntities.cs b/src/Jiaowu.Api/Domain/Academic/ComprehensiveAssessmentEntities.cs new file mode 100644 index 0000000..a37b5e5 --- /dev/null +++ b/src/Jiaowu.Api/Domain/Academic/ComprehensiveAssessmentEntities.cs @@ -0,0 +1,202 @@ +using Jiaowu.Api.Domain.Common; +using Jiaowu.Api.Domain.Identity; + +namespace Jiaowu.Api.Domain.Academic; + +public sealed class ComprehensiveAssessmentScheme : EntityBase +{ + public required string Name { get; set; } + public int Version { get; set; } = 1; + public Guid? CollegeId { get; set; } + public College? College { get; set; } + public ComprehensiveAssessmentSchemeStatus Status { get; set; } = + ComprehensiveAssessmentSchemeStatus.Draft; + public ComprehensiveAssessmentRankingScope RankingScope { get; set; } = + ComprehensiveAssessmentRankingScope.AdministrativeClass; + public int PublicityDays { get; set; } = 7; + public string? Notes { get; set; } + public Guid CreatedByUserId { get; set; } + public ApplicationUser? CreatedByUser { get; set; } + public DateTime? PublishedAt { get; set; } + public ICollection Dimensions { get; set; } = []; + public ICollection Rules { get; set; } = []; +} + +public sealed class ComprehensiveAssessmentDimension : EntityBase +{ + public Guid ComprehensiveAssessmentSchemeId { get; set; } + public ComprehensiveAssessmentScheme? Scheme { get; set; } + public required string Code { get; set; } + public required string Name { get; set; } + public ComprehensiveAssessmentSourceType SourceType { get; set; } + public decimal Weight { get; set; } + public decimal MaxScore { get; set; } = 100; + public int SortOrder { get; set; } + public bool IsRequired { get; set; } = true; + public string? SettingsJson { get; set; } +} + +public sealed class ComprehensiveAssessmentRule : EntityBase +{ + public Guid ComprehensiveAssessmentSchemeId { get; set; } + public ComprehensiveAssessmentScheme? Scheme { get; set; } + public Guid ComprehensiveAssessmentDimensionId { get; set; } + public ComprehensiveAssessmentDimension? Dimension { get; set; } + public required string Category { get; set; } + public required string Level { get; set; } + public decimal Score { get; set; } + public decimal? CategoryCap { get; set; } + public int SortOrder { get; set; } +} + +public sealed class ComprehensiveAssessmentBatch : EntityBase +{ + public Guid ComprehensiveAssessmentSchemeId { get; set; } + public ComprehensiveAssessmentScheme? Scheme { get; set; } + public required string Name { get; set; } + public required string AcademicYear { get; set; } + public Guid? AcademicTermId { get; set; } + public AcademicTerm? AcademicTerm { get; set; } + public Guid? CollegeId { get; set; } + public College? College { get; set; } + public ComprehensiveAssessmentBatchStatus Status { get; set; } = + ComprehensiveAssessmentBatchStatus.Draft; + public ComprehensiveAssessmentCalculationStatus CalculationStatus { get; set; } = + ComprehensiveAssessmentCalculationStatus.NotStarted; + public string? CalculationError { get; set; } + public DateTime? CalculatedAt { get; set; } + public DateTime? PublicityStartsAt { get; set; } + public DateTime? PublicityEndsAt { get; set; } + public DateTime? PublishedAt { get; set; } + public int PublicationCount { get; set; } + public string? Notes { get; set; } + public Guid CreatedByUserId { get; set; } + public ApplicationUser? CreatedByUser { get; set; } + public ICollection Declarations { get; set; } = []; + public ICollection Results { get; set; } = []; + public ICollection Publications { get; set; } = []; +} + +public sealed class ComprehensiveAssessmentDeclaration : EntityBase +{ + public Guid ComprehensiveAssessmentBatchId { get; set; } + public ComprehensiveAssessmentBatch? Batch { get; set; } + public Guid StudentId { get; set; } + public Student? Student { get; set; } + public Guid ComprehensiveAssessmentDimensionId { get; set; } + public ComprehensiveAssessmentDimension? Dimension { get; set; } + public Guid? ComprehensiveAssessmentRuleId { get; set; } + public ComprehensiveAssessmentRule? Rule { get; set; } + public required string Title { get; set; } + public required string Category { get; set; } + public required string Level { get; set; } + public DateOnly OccurredOn { get; set; } + public string? EvidenceDescription { get; set; } + public string? EvidenceUrl { get; set; } + public decimal ClaimedScore { get; set; } + public decimal? ApprovedScore { get; set; } + public ComprehensiveAssessmentDeclarationStatus Status { get; set; } = + ComprehensiveAssessmentDeclarationStatus.Draft; + public DateTime? SubmittedAt { get; set; } + public Guid? CounselorReviewedByUserId { get; set; } + public DateTime? CounselorReviewedAt { get; set; } + public string? CounselorComment { get; set; } + public Guid? CollegeReviewedByUserId { get; set; } + public DateTime? CollegeReviewedAt { get; set; } + public string? CollegeComment { get; set; } +} + +public sealed class ComprehensiveAssessmentResult : EntityBase +{ + public Guid ComprehensiveAssessmentBatchId { get; set; } + public ComprehensiveAssessmentBatch? Batch { get; set; } + public Guid StudentId { get; set; } + public Student? Student { get; set; } + public decimal TotalScore { get; set; } + public int? ClassRank { get; set; } + public int? MajorRank { get; set; } + public int? CollegeRank { get; set; } + public int MissingRequiredDimensionCount { get; set; } + public DateTime CalculatedAt { get; set; } + public ICollection Details { get; set; } = []; +} + +public sealed class ComprehensiveAssessmentResultDetail : EntityBase +{ + public Guid ComprehensiveAssessmentResultId { get; set; } + public ComprehensiveAssessmentResult? Result { get; set; } + public Guid ComprehensiveAssessmentDimensionId { get; set; } + public ComprehensiveAssessmentDimension? Dimension { get; set; } + public ComprehensiveAssessmentSourceStatus SourceStatus { get; set; } + public decimal? RawScore { get; set; } + public decimal WeightedScore { get; set; } + public string? Explanation { get; set; } + public string? SourceSnapshotJson { get; set; } +} + +public sealed class ComprehensiveAssessmentAppeal : EntityBase +{ + public Guid ComprehensiveAssessmentBatchId { get; set; } + public ComprehensiveAssessmentBatch? Batch { get; set; } + public Guid StudentId { get; set; } + public Student? Student { get; set; } + public Guid? ComprehensiveAssessmentResultDetailId { get; set; } + public ComprehensiveAssessmentResultDetail? ResultDetail { get; set; } + public required string Reason { get; set; } + public ComprehensiveAssessmentAppealStatus Status { get; set; } = + ComprehensiveAssessmentAppealStatus.Submitted; + public string? ReviewComment { get; set; } + public Guid? ReviewedByUserId { get; set; } + public DateTime? ReviewedAt { get; set; } +} + +public sealed class ComprehensiveAssessmentPublication : EntityBase +{ + public Guid ComprehensiveAssessmentBatchId { get; set; } + public ComprehensiveAssessmentBatch? Batch { get; set; } + public int Version { get; set; } + public ComprehensiveAssessmentPublicationType Type { get; set; } + public Guid PublishedByUserId { get; set; } + public ApplicationUser? PublishedByUser { get; set; } + public DateTime PublishedAt { get; set; } + public string? Note { get; set; } +} + +public enum ComprehensiveAssessmentSchemeStatus { Draft = 1, Published = 2, Archived = 3 } +public enum ComprehensiveAssessmentRankingScope { AdministrativeClass = 1, Major = 2, College = 3 } +public enum ComprehensiveAssessmentSourceType +{ + Academic = 1, + PhysicalFitness = 2, + DormitoryHygiene = 3, + Attendance = 4, + Declaration = 5 +} +public enum ComprehensiveAssessmentBatchStatus +{ + Draft = 1, + Collecting = 2, + Reviewing = 3, + Publicizing = 4, + Published = 5 +} +public enum ComprehensiveAssessmentCalculationStatus +{ + NotStarted = 0, + Queued = 1, + Running = 2, + Succeeded = 3, + Failed = 4 +} +public enum ComprehensiveAssessmentDeclarationStatus +{ + Draft = 1, + Submitted = 2, + CounselorApproved = 3, + Approved = 4, + Rejected = 5, + Withdrawn = 6 +} +public enum ComprehensiveAssessmentSourceStatus { Available = 1, Missing = 2, Exempt = 3 } +public enum ComprehensiveAssessmentAppealStatus { Submitted = 1, Approved = 2, Rejected = 3 } +public enum ComprehensiveAssessmentPublicationType { Publicity = 1, Final = 2, Revision = 3 } diff --git a/src/Jiaowu.Api/Domain/Identity/ApplicationUser.cs b/src/Jiaowu.Api/Domain/Identity/ApplicationUser.cs index 9e091a7..66b3bb8 100644 --- a/src/Jiaowu.Api/Domain/Identity/ApplicationUser.cs +++ b/src/Jiaowu.Api/Domain/Identity/ApplicationUser.cs @@ -50,6 +50,7 @@ public static class SystemRoles public const string MaintenanceStaff = "MaintenanceStaff"; public const string PhysicalEducationAdmin = "PhysicalEducationAdmin"; public const string DormitoryAdmin = "DormitoryAdmin"; + public const string StudentAffairsAdmin = "StudentAffairsAdmin"; public static readonly string[] All = [ @@ -63,6 +64,7 @@ public static class SystemRoles MaintenanceAdmin, MaintenanceStaff, PhysicalEducationAdmin, - DormitoryAdmin + DormitoryAdmin, + StudentAffairsAdmin ]; } diff --git a/src/Jiaowu.Api/Domain/System/BackgroundJobOutboxMessage.cs b/src/Jiaowu.Api/Domain/System/BackgroundJobOutboxMessage.cs index 22830ea..3f1c310 100644 --- a/src/Jiaowu.Api/Domain/System/BackgroundJobOutboxMessage.cs +++ b/src/Jiaowu.Api/Domain/System/BackgroundJobOutboxMessage.cs @@ -38,7 +38,8 @@ public enum BackgroundJobKind GraduationAuditCalculation = 8, DegreeAwardCalculation = 9, DormitoryAutomaticAllocation = 10, - DormitoryHygieneCalculation = 11 + DormitoryHygieneCalculation = 11, + ComprehensiveAssessmentCalculation = 12 } public enum BackgroundJobOutboxState diff --git a/src/Jiaowu.Api/Infrastructure/Assessments/ComprehensiveAssessmentCalculationProcessor.cs b/src/Jiaowu.Api/Infrastructure/Assessments/ComprehensiveAssessmentCalculationProcessor.cs new file mode 100644 index 0000000..86a7cb0 --- /dev/null +++ b/src/Jiaowu.Api/Infrastructure/Assessments/ComprehensiveAssessmentCalculationProcessor.cs @@ -0,0 +1,272 @@ +using System.Text.Json; +using Jiaowu.Api.Domain.Academic; +using Jiaowu.Api.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; + +namespace Jiaowu.Api.Infrastructure.Assessments; + +public sealed class ComprehensiveAssessmentCalculationProcessor(AppDbContext db) +{ + public async Task ProcessAsync(Guid batchId, CancellationToken token) + { + var batch = await db.ComprehensiveAssessmentBatches + .Include(x => x.Scheme).ThenInclude(x => x!.Dimensions) + .FirstOrDefaultAsync(x => x.Id == batchId, token); + if (batch is null || batch.CalculationStatus == ComprehensiveAssessmentCalculationStatus.Succeeded) + return; + + batch.CalculationStatus = ComprehensiveAssessmentCalculationStatus.Running; + batch.CalculationError = null; + await db.SaveChangesAsync(token); + + try + { + var dimensions = batch.Scheme!.Dimensions.OrderBy(x => x.SortOrder).ToArray(); + if (dimensions.Length == 0 || dimensions.Sum(x => x.Weight) != 100) + throw new InvalidOperationException("测评方案维度权重之和必须为 100%。"); + + var studentsQuery = db.Students.AsNoTracking() + .Where(x => !x.IsArchived && (x.Status == StudentStatus.Active || x.Status == StudentStatus.Suspended)); + if (batch.CollegeId.HasValue) + studentsQuery = studentsQuery.Where(x => x.AdministrativeClass!.Major!.CollegeId == batch.CollegeId); + var students = await studentsQuery.OrderBy(x => x.StudentNumber) + .Select(x => new StudentSnapshot(x.Id, x.StudentNumber, x.AdministrativeClassId, + x.AdministrativeClass!.MajorId, x.AdministrativeClass.Major!.CollegeId)) + .ToListAsync(token); + var studentIds = students.Select(x => x.Id).ToArray(); + + var academic = await LoadAcademicAsync(batch, studentIds, token); + var physical = await LoadPhysicalAsync(batch, studentIds, token); + var dormitory = await LoadDormitoryAsync(batch, studentIds, token); + var attendance = await LoadAttendanceAsync(batch, studentIds, token); + var declarationRows = await db.ComprehensiveAssessmentDeclarations.AsNoTracking() + .Where(x => x.ComprehensiveAssessmentBatchId == batchId && + x.Status == ComprehensiveAssessmentDeclarationStatus.Approved) + .Select(x => new + { + x.StudentId, DimensionId = x.ComprehensiveAssessmentDimensionId, x.Category, + Score = x.ApprovedScore ?? x.ClaimedScore, + CategoryCap = x.Rule != null ? x.Rule.CategoryCap : null + }).ToListAsync(token); + var declarationMap = declarationRows + .GroupBy(x => new { x.StudentId, x.DimensionId }) + .ToDictionary(x => (x.Key.StudentId, x.Key.DimensionId), x => + { + var score = x.GroupBy(item => item.Category).Sum(category => + { + var total = category.Sum(item => item.Score); + var cap = category.Select(item => item.CategoryCap).FirstOrDefault(value => value.HasValue); + return cap.HasValue ? Math.Min(total, cap.Value) : total; + }); + return new DeclarationValue(score, x.Count()); + }); + + await db.ComprehensiveAssessmentResults.Where(x => x.ComprehensiveAssessmentBatchId == batchId) + .ExecuteDeleteAsync(token); + + var now = DateTime.UtcNow; + var results = new List(students.Count); + foreach (var student in students) + { + var result = new ComprehensiveAssessmentResult + { + ComprehensiveAssessmentBatchId = batchId, + StudentId = student.Id, + CalculatedAt = now + }; + foreach (var dimension in dimensions) + { + var source = dimension.SourceType switch + { + ComprehensiveAssessmentSourceType.Academic => academic.GetValueOrDefault(student.Id), + ComprehensiveAssessmentSourceType.PhysicalFitness => physical.GetValueOrDefault(student.Id), + ComprehensiveAssessmentSourceType.DormitoryHygiene => dormitory.GetValueOrDefault(student.Id), + ComprehensiveAssessmentSourceType.Attendance => attendance.GetValueOrDefault(student.Id), + ComprehensiveAssessmentSourceType.Declaration => DeclarationSource(student.Id, dimension, declarationMap), + _ => null + }; + var status = source?.Status ?? ComprehensiveAssessmentSourceStatus.Missing; + var raw = source?.Score; + var weighted = raw.HasValue + ? Math.Round(Math.Clamp(raw.Value, 0, dimension.MaxScore) / dimension.MaxScore * dimension.Weight, 2) + : 0; + result.Details.Add(new ComprehensiveAssessmentResultDetail + { + ComprehensiveAssessmentDimensionId = dimension.Id, + SourceStatus = status, + RawScore = raw, + WeightedScore = weighted, + Explanation = source?.Explanation ?? "没有可用的正式数据。", + SourceSnapshotJson = source?.SnapshotJson + }); + result.TotalScore += weighted; + if (dimension.IsRequired && status == ComprehensiveAssessmentSourceStatus.Missing) + result.MissingRequiredDimensionCount++; + } + result.TotalScore = Math.Round(result.TotalScore, 2); + results.Add(result); + } + + ApplyRanks(results, students, dimensions); + foreach (var chunk in results.Chunk(500)) + { + db.ComprehensiveAssessmentResults.AddRange(chunk); + await db.SaveChangesAsync(token); + } + + batch.CalculationStatus = ComprehensiveAssessmentCalculationStatus.Succeeded; + batch.CalculatedAt = now; + await db.SaveChangesAsync(token); + } + catch (Exception exception) + { + batch.CalculationStatus = ComprehensiveAssessmentCalculationStatus.Failed; + batch.CalculationError = exception.Message.Length > 2000 ? exception.Message[..2000] : exception.Message; + await db.SaveChangesAsync(CancellationToken.None); + throw; + } + } + + private async Task> LoadAcademicAsync( + ComprehensiveAssessmentBatch batch, Guid[] studentIds, CancellationToken token) + { + if (batch.AcademicTermId.HasValue) + { + var rows = await db.StudentAcademicTermStatistics.AsNoTracking() + .Where(x => x.AcademicTermId == batch.AcademicTermId && studentIds.Contains(x.StudentId)) + .Select(x => new { x.StudentId, x.AcademicTermId, x.CourseCount, x.Gpa, x.WeightedAverageScore, x.AverageScore }) + .ToListAsync(token); + return rows.ToDictionary(x => x.StudentId, x => Source( + x.WeightedAverageScore ?? x.AverageScore, + $"已发布课程 {x.CourseCount} 门,加权平均分 {x.WeightedAverageScore ?? x.AverageScore:0.##}。", + new { x.AcademicTermId, x.CourseCount, x.Gpa, x.WeightedAverageScore, x.AverageScore })); + } + + var allRows = await db.StudentAcademicStatistics.AsNoTracking() + .Where(x => studentIds.Contains(x.StudentId)) + .Select(x => new { x.StudentId, x.CourseCount, x.Gpa, x.WeightedAverageScore, x.AverageScore }) + .ToListAsync(token); + return allRows.ToDictionary(x => x.StudentId, x => Source( + x.WeightedAverageScore ?? x.AverageScore, + $"累计已发布课程 {x.CourseCount} 门,加权平均分 {x.WeightedAverageScore ?? x.AverageScore:0.##}。", + new { x.CourseCount, x.Gpa, x.WeightedAverageScore, x.AverageScore })); + } + + private async Task> LoadPhysicalAsync( + ComprehensiveAssessmentBatch batch, Guid[] studentIds, CancellationToken token) + { + var rows = await db.PhysicalTestRecords.AsNoTracking() + .Where(x => studentIds.Contains(x.StudentId) && + x.PhysicalTestBatch!.Status == PhysicalTestBatchStatus.Published && + x.PhysicalTestBatch.AcademicYear == batch.AcademicYear) + .Select(x => new { x.StudentId, x.Status, x.TotalScore, x.SpecialReason, + BatchId = x.PhysicalTestBatchId, x.PhysicalTestBatch!.TestDate }) + .ToListAsync(token); + return rows.GroupBy(x => x.StudentId).ToDictionary(x => x.Key, group => + { + var row = group.OrderByDescending(x => x.TestDate).ThenByDescending(x => x.BatchId).First(); + if (row.Status == PhysicalTestRecordStatus.Exempt) + return new SourceValue(null, ComprehensiveAssessmentSourceStatus.Exempt, + row.SpecialReason ?? "体测免测。", JsonSerializer.Serialize(row)); + return new SourceValue(row.TotalScore, + row.TotalScore.HasValue ? ComprehensiveAssessmentSourceStatus.Available : ComprehensiveAssessmentSourceStatus.Missing, + row.Status == PhysicalTestRecordStatus.Normal ? $"体测成绩 {row.TotalScore:0.##} 分。" : row.SpecialReason ?? "体测成绩缺失。", + JsonSerializer.Serialize(row)); + }); + } + + private async Task> LoadDormitoryAsync( + ComprehensiveAssessmentBatch batch, Guid[] studentIds, CancellationToken token) + { + if (!batch.AcademicTermId.HasValue) return []; + var calculationId = await db.DormitoryHygieneCalculations.AsNoTracking() + .Where(x => x.AcademicTermId == batch.AcademicTermId && x.Status == DormitoryHygieneCalculationStatus.Succeeded) + .OrderByDescending(x => x.CompletedAt).ThenByDescending(x => x.CreatedAt) + .Select(x => (Guid?)x.Id).FirstOrDefaultAsync(token); + if (!calculationId.HasValue) return []; + var rows = await db.DormitoryHygieneStudentSummaries.AsNoTracking() + .Where(x => x.DormitoryHygieneCalculationId == calculationId && studentIds.Contains(x.StudentId)) + .Select(x => new { x.StudentId, x.DormitoryHygieneCalculationId, x.AverageScore, x.ExpectedBatchCount, x.IncludedScoreCount, x.MissingScoreCount, x.ViolationCount }) + .ToListAsync(token); + return rows.ToDictionary(x => x.StudentId, x => Source(x.AverageScore, + $"纳入 {x.IncludedScoreCount}/{x.ExpectedBatchCount} 次检查,缺失 {x.MissingScoreCount} 次,违纪 {x.ViolationCount} 次。", + new { x.DormitoryHygieneCalculationId, x.AverageScore, x.ExpectedBatchCount, x.IncludedScoreCount, x.MissingScoreCount, x.ViolationCount })); + } + + private async Task> LoadAttendanceAsync( + ComprehensiveAssessmentBatch batch, Guid[] studentIds, CancellationToken token) + { + if (!batch.AcademicTermId.HasValue) return []; + var term = await db.AcademicTerms.AsNoTracking().FirstAsync(x => x.Id == batch.AcademicTermId, token); + var from = term.StartDate.ToDateTime(TimeOnly.MinValue); + var to = term.EndDate.ToDateTime(TimeOnly.MaxValue); + var rows = await db.AttendanceRecords.AsNoTracking() + .Where(x => studentIds.Contains(x.StudentId) && + x.AttendanceSheet!.Status == AttendanceSheetStatus.Submitted && + x.AttendanceSheet.AttendanceDate >= from && x.AttendanceSheet.AttendanceDate <= to && + x.AppealStatus != AttendanceAppealStatus.Pending) + .GroupBy(x => x.StudentId) + .Select(group => new + { + StudentId = group.Key, + Count = group.Count(), + Absent = group.Count(x => x.Status == AttendanceStatus.Absent), + Late = group.Count(x => x.Status == AttendanceStatus.Late), + Leave = group.Count(x => x.Status == AttendanceStatus.Leave) + }).ToListAsync(token); + return rows.ToDictionary(x => x.StudentId, x => Source( + Math.Max(0, 100 - x.Absent * 5 - x.Late * 2), + $"有效考勤 {x.Count} 次,缺勤 {x.Absent} 次,迟到 {x.Late} 次,请假 {x.Leave} 次。", + x)); + } + + private static SourceValue DeclarationSource(Guid studentId, ComprehensiveAssessmentDimension dimension, + IReadOnlyDictionary<(Guid StudentId, Guid DimensionId), DeclarationValue> map) + { + if (!map.TryGetValue((studentId, dimension.Id), out var row)) + return Source(0, "没有审核通过的加分材料。", new { count = 0 }); + var score = row.Score; + var count = row.Count; + return Source(Math.Min(score, dimension.MaxScore), $"审核通过 {count} 项材料,计 {score:0.##} 分。", + new { count, approvedScore = score }); + } + + private static SourceValue Source(decimal? score, string explanation, object snapshot) => + new(score, score.HasValue ? ComprehensiveAssessmentSourceStatus.Available : ComprehensiveAssessmentSourceStatus.Missing, + explanation, JsonSerializer.Serialize(snapshot)); + + private static void ApplyRanks(List results, + IReadOnlyList students, IReadOnlyList dimensions) + { + var studentMap = students.ToDictionary(x => x.Id); + var academicId = dimensions.FirstOrDefault(x => x.SourceType == ComprehensiveAssessmentSourceType.Academic)?.Id; + foreach (var grouping in results.GroupBy(x => studentMap[x.StudentId].ClassId)) + AssignRank(grouping, x => x.ClassRank = x.Rank, academicId, studentMap); + foreach (var grouping in results.GroupBy(x => studentMap[x.StudentId].MajorId)) + AssignRank(grouping, x => x.MajorRank = x.Rank, academicId, studentMap); + foreach (var grouping in results.GroupBy(x => studentMap[x.StudentId].CollegeId)) + AssignRank(grouping, x => x.CollegeRank = x.Rank, academicId, studentMap); + } + + private static void AssignRank(IEnumerable source, + Action assign, Guid? academicId, IReadOnlyDictionary students) + { + var ordered = source.OrderByDescending(x => x.TotalScore) + .ThenByDescending(x => academicId.HasValue + ? x.Details.FirstOrDefault(d => d.ComprehensiveAssessmentDimensionId == academicId)?.RawScore ?? -1 + : -1) + .ThenBy(x => students[x.StudentId].StudentNumber).ToArray(); + for (var index = 0; index < ordered.Length; index++) + assign(new RankedResult(ordered[index], index + 1)); + } + + private sealed record StudentSnapshot(Guid Id, string StudentNumber, Guid ClassId, Guid MajorId, Guid CollegeId); + private sealed record SourceValue(decimal? Score, ComprehensiveAssessmentSourceStatus Status, string Explanation, string SnapshotJson); + private sealed record DeclarationValue(decimal Score, int Count); + private sealed record RankedResult(ComprehensiveAssessmentResult Result, int Rank) + { + public int? ClassRank { set => Result.ClassRank = value; } + public int? MajorRank { set => Result.MajorRank = value; } + public int? CollegeRank { set => Result.CollegeRank = value; } + } +} diff --git a/src/Jiaowu.Api/Infrastructure/Auth/CurrentUserDataScope.cs b/src/Jiaowu.Api/Infrastructure/Auth/CurrentUserDataScope.cs index 204a296..2d09942 100644 --- a/src/Jiaowu.Api/Infrastructure/Auth/CurrentUserDataScope.cs +++ b/src/Jiaowu.Api/Infrastructure/Auth/CurrentUserDataScope.cs @@ -70,6 +70,7 @@ public static class EffectiveDataScopeResolver [SystemRoles.MaintenanceStaff] = DataScope.Self, [SystemRoles.PhysicalEducationAdmin] = DataScope.All, [SystemRoles.DormitoryAdmin] = DataScope.All, + [SystemRoles.StudentAffairsAdmin] = DataScope.All, [SystemRoles.CollegeAdmin] = DataScope.College, [SystemRoles.Counselor] = DataScope.Class, [SystemRoles.Teacher] = DataScope.Self, diff --git a/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobOptions.cs b/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobOptions.cs index f751ded..ce0dc15 100644 --- a/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobOptions.cs +++ b/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobOptions.cs @@ -21,6 +21,7 @@ public sealed class BackgroundJobOptions public int DegreeAwardCalculationConcurrency { get; set; } = 1; public int DormitoryAutomaticAllocationConcurrency { get; set; } = 1; public int DormitoryHygieneCalculationConcurrency { get; set; } = 1; + public int ComprehensiveAssessmentCalculationConcurrency { get; set; } = 1; public string Exchange { get; set; } = "jiaowu.background-jobs"; public string QueuePrefix { get; set; } = "jiaowu.background-jobs"; public bool UseQuorumQueues { get; set; } = true; @@ -46,6 +47,7 @@ public sealed class BackgroundJobOptions BackgroundJobKind.DegreeAwardCalculation => DegreeAwardCalculationConcurrency, BackgroundJobKind.DormitoryAutomaticAllocation => DormitoryAutomaticAllocationConcurrency, BackgroundJobKind.DormitoryHygieneCalculation => DormitoryHygieneCalculationConcurrency, + BackgroundJobKind.ComprehensiveAssessmentCalculation => ComprehensiveAssessmentCalculationConcurrency, _ => throw new ArgumentOutOfRangeException(nameof(kind), kind, null) }; } diff --git a/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobOutboxPublisher.cs b/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobOutboxPublisher.cs index 7b910a5..3ec907e 100644 --- a/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobOutboxPublisher.cs +++ b/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobOutboxPublisher.cs @@ -158,6 +158,15 @@ public sealed class BackgroundJobOutboxPublisher( message.JobId == x.Id)) .Select(x => x.Id) .ToListAsync(cancellationToken); + var comprehensiveAssessmentJobs = await db.ComprehensiveAssessmentBatches.AsNoTracking() + .Where(x => + (x.CalculationStatus == ComprehensiveAssessmentCalculationStatus.Queued || + x.CalculationStatus == ComprehensiveAssessmentCalculationStatus.Running) && + !db.BackgroundJobOutboxMessages.Any(message => + message.JobKind == BackgroundJobKind.ComprehensiveAssessmentCalculation && + message.JobId == x.Id)) + .Select(x => x.Id) + .ToListAsync(cancellationToken); var missingKeys = automaticJobs .Select(id => (BackgroundJobKind.AutomaticSchedule, id)) @@ -177,6 +186,8 @@ public sealed class BackgroundJobOutboxPublisher( (BackgroundJobKind.DormitoryAutomaticAllocation, id))) .Concat(dormitoryHygieneCalculationJobs.Select(id => (BackgroundJobKind.DormitoryHygieneCalculation, id))) + .Concat(comprehensiveAssessmentJobs.Select(id => + (BackgroundJobKind.ComprehensiveAssessmentCalculation, id))) .ToList(); foreach (var (kind, jobId) in missingKeys) { diff --git a/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobRunner.cs b/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobRunner.cs index c61328f..00eaefd 100644 --- a/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobRunner.cs +++ b/src/Jiaowu.Api/Infrastructure/BackgroundJobs/BackgroundJobRunner.cs @@ -9,6 +9,7 @@ using Jiaowu.Api.Infrastructure.Scheduling; using Jiaowu.Api.Controllers; using Jiaowu.Api.Infrastructure.Auth; using Jiaowu.Api.Infrastructure.Dormitories; +using Jiaowu.Api.Infrastructure.Assessments; using Microsoft.EntityFrameworkCore; namespace Jiaowu.Api.Infrastructure.BackgroundJobs; @@ -127,6 +128,11 @@ public sealed class BackgroundJobRunner( .GetRequiredService() .ProcessAsync(message.JobId, cancellationToken); break; + case BackgroundJobKind.ComprehensiveAssessmentCalculation: + await scope.ServiceProvider + .GetRequiredService() + .ProcessAsync(message.JobId, cancellationToken); + break; default: throw new InvalidOperationException( $"Unsupported background job kind '{message.JobKind}'."); @@ -438,6 +444,13 @@ public sealed class BackgroundJobRunner( .SetProperty(x => x.ErrorMessage, error) .SetProperty(x => x.CompletedAt, completedAt), cancellationToken); break; + case BackgroundJobKind.ComprehensiveAssessmentCalculation: + await db.ComprehensiveAssessmentBatches.Where(x => x.Id == message.JobId && + x.CalculationStatus != ComprehensiveAssessmentCalculationStatus.Succeeded) + .ExecuteUpdateAsync(setters => setters + .SetProperty(x => x.CalculationStatus, ComprehensiveAssessmentCalculationStatus.Failed) + .SetProperty(x => x.CalculationError, error), cancellationToken); + break; default: throw new ArgumentOutOfRangeException( nameof(message.JobKind), diff --git a/src/Jiaowu.Api/Infrastructure/BackgroundJobs/RabbitMqBackgroundJobs.cs b/src/Jiaowu.Api/Infrastructure/BackgroundJobs/RabbitMqBackgroundJobs.cs index 0442041..e9600f8 100644 --- a/src/Jiaowu.Api/Infrastructure/BackgroundJobs/RabbitMqBackgroundJobs.cs +++ b/src/Jiaowu.Api/Infrastructure/BackgroundJobs/RabbitMqBackgroundJobs.cs @@ -324,7 +324,8 @@ internal static class RabbitMqBackgroundJobTopology BackgroundJobKind.GraduationAuditCalculation, BackgroundJobKind.DegreeAwardCalculation, BackgroundJobKind.DormitoryAutomaticAllocation, - BackgroundJobKind.DormitoryHygieneCalculation + BackgroundJobKind.DormitoryHygieneCalculation, + BackgroundJobKind.ComprehensiveAssessmentCalculation ]; public static async Task CreateConnectionAsync( @@ -428,6 +429,7 @@ internal static class RabbitMqBackgroundJobTopology BackgroundJobKind.DegreeAwardCalculation => "degree-award.calculate", BackgroundJobKind.DormitoryAutomaticAllocation => "dormitory.allocate", BackgroundJobKind.DormitoryHygieneCalculation => "dormitory-hygiene.calculate", + BackgroundJobKind.ComprehensiveAssessmentCalculation => "comprehensive-assessment.calculate", _ => throw new ArgumentOutOfRangeException(nameof(kind), kind, null) }; diff --git a/src/Jiaowu.Api/Infrastructure/Persistence/AppDbContext.cs b/src/Jiaowu.Api/Infrastructure/Persistence/AppDbContext.cs index f378f56..470fb07 100644 --- a/src/Jiaowu.Api/Infrastructure/Persistence/AppDbContext.cs +++ b/src/Jiaowu.Api/Infrastructure/Persistence/AppDbContext.cs @@ -126,6 +126,15 @@ public sealed class AppDbContext(DbContextOptions options) public DbSet DormitoryHygieneCalculations => Set(); public DbSet DormitoryHygieneCalculationBatches => Set(); public DbSet DormitoryHygieneStudentSummaries => Set(); + public DbSet ComprehensiveAssessmentSchemes => Set(); + public DbSet ComprehensiveAssessmentDimensions => Set(); + public DbSet ComprehensiveAssessmentRules => Set(); + public DbSet ComprehensiveAssessmentBatches => Set(); + public DbSet ComprehensiveAssessmentDeclarations => Set(); + public DbSet ComprehensiveAssessmentResults => Set(); + public DbSet ComprehensiveAssessmentResultDetails => Set(); + public DbSet ComprehensiveAssessmentAppeals => Set(); + public DbSet ComprehensiveAssessmentPublications => Set(); public DbSet AttendanceSheets => Set(); public DbSet AttendanceRecords => Set(); public DbSet AttendanceCheckInAttempts => @@ -1717,6 +1726,120 @@ public sealed class AppDbContext(DbContextOptions options) entity.HasOne(x => x.Student).WithMany().HasForeignKey(x => x.StudentId) .OnDelete(DeleteBehavior.Restrict); }); + builder.Entity(entity => + { + entity.Property(x => x.Name).HasMaxLength(150); + entity.Property(x => x.Notes).HasMaxLength(1000); + entity.HasIndex(x => new { x.CollegeId, x.Status, x.CreatedAt }); + entity.HasOne(x => x.College).WithMany().HasForeignKey(x => x.CollegeId) + .OnDelete(DeleteBehavior.Restrict); + entity.HasOne(x => x.CreatedByUser).WithMany().HasForeignKey(x => x.CreatedByUserId) + .OnDelete(DeleteBehavior.Restrict); + }); + builder.Entity(entity => + { + entity.Property(x => x.Code).HasMaxLength(50); + entity.Property(x => x.Name).HasMaxLength(100); + entity.Property(x => x.Weight).HasPrecision(5, 2); + entity.Property(x => x.MaxScore).HasPrecision(7, 2); + entity.Property(x => x.SettingsJson).HasColumnType("text"); + entity.HasIndex(x => new { x.ComprehensiveAssessmentSchemeId, x.Code }).IsUnique(); + entity.HasOne(x => x.Scheme).WithMany(x => x.Dimensions) + .HasForeignKey(x => x.ComprehensiveAssessmentSchemeId).OnDelete(DeleteBehavior.Cascade); + }); + builder.Entity(entity => + { + entity.Property(x => x.Category).HasMaxLength(100); + entity.Property(x => x.Level).HasMaxLength(100); + entity.Property(x => x.Score).HasPrecision(7, 2); + entity.Property(x => x.CategoryCap).HasPrecision(7, 2); + entity.HasIndex(x => new { x.ComprehensiveAssessmentSchemeId, x.ComprehensiveAssessmentDimensionId, x.Category, x.Level }).IsUnique(); + entity.HasOne(x => x.Scheme).WithMany(x => x.Rules) + .HasForeignKey(x => x.ComprehensiveAssessmentSchemeId).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(x => x.Dimension).WithMany() + .HasForeignKey(x => x.ComprehensiveAssessmentDimensionId).OnDelete(DeleteBehavior.Cascade); + }); + builder.Entity(entity => + { + entity.Property(x => x.Name).HasMaxLength(150); + entity.Property(x => x.AcademicYear).HasMaxLength(20); + entity.Property(x => x.CalculationError).HasMaxLength(2000); + entity.Property(x => x.Notes).HasMaxLength(1000); + entity.HasIndex(x => new { x.AcademicYear, x.CollegeId, x.Status, x.CreatedAt }); + entity.HasOne(x => x.Scheme).WithMany().HasForeignKey(x => x.ComprehensiveAssessmentSchemeId) + .OnDelete(DeleteBehavior.Restrict); + entity.HasOne(x => x.AcademicTerm).WithMany().HasForeignKey(x => x.AcademicTermId) + .OnDelete(DeleteBehavior.Restrict); + entity.HasOne(x => x.College).WithMany().HasForeignKey(x => x.CollegeId) + .OnDelete(DeleteBehavior.Restrict); + entity.HasOne(x => x.CreatedByUser).WithMany().HasForeignKey(x => x.CreatedByUserId) + .OnDelete(DeleteBehavior.Restrict); + }); + builder.Entity(entity => + { + entity.Property(x => x.Title).HasMaxLength(200); + entity.Property(x => x.Category).HasMaxLength(100); + entity.Property(x => x.Level).HasMaxLength(100); + entity.Property(x => x.EvidenceDescription).HasMaxLength(1000); + entity.Property(x => x.EvidenceUrl).HasMaxLength(500); + entity.Property(x => x.ClaimedScore).HasPrecision(7, 2); + entity.Property(x => x.ApprovedScore).HasPrecision(7, 2); + entity.Property(x => x.CounselorComment).HasMaxLength(500); + entity.Property(x => x.CollegeComment).HasMaxLength(500); + entity.HasIndex(x => new { x.ComprehensiveAssessmentBatchId, x.StudentId, x.Status }); + entity.HasIndex(x => new { x.StudentId, x.OccurredOn }); + entity.HasOne(x => x.Batch).WithMany(x => x.Declarations) + .HasForeignKey(x => x.ComprehensiveAssessmentBatchId).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(x => x.Student).WithMany().HasForeignKey(x => x.StudentId) + .OnDelete(DeleteBehavior.Restrict); + entity.HasOne(x => x.Dimension).WithMany().HasForeignKey(x => x.ComprehensiveAssessmentDimensionId) + .OnDelete(DeleteBehavior.Restrict); + entity.HasOne(x => x.Rule).WithMany().HasForeignKey(x => x.ComprehensiveAssessmentRuleId) + .OnDelete(DeleteBehavior.SetNull); + }); + builder.Entity(entity => + { + entity.Property(x => x.TotalScore).HasPrecision(8, 2); + entity.HasIndex(x => new { x.ComprehensiveAssessmentBatchId, x.StudentId }).IsUnique(); + entity.HasIndex(x => new { x.ComprehensiveAssessmentBatchId, x.ClassRank }); + entity.HasOne(x => x.Batch).WithMany(x => x.Results) + .HasForeignKey(x => x.ComprehensiveAssessmentBatchId).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(x => x.Student).WithMany().HasForeignKey(x => x.StudentId) + .OnDelete(DeleteBehavior.Restrict); + }); + builder.Entity(entity => + { + entity.Property(x => x.RawScore).HasPrecision(8, 2); + entity.Property(x => x.WeightedScore).HasPrecision(8, 2); + entity.Property(x => x.Explanation).HasMaxLength(1000); + entity.Property(x => x.SourceSnapshotJson).HasColumnType("longtext"); + entity.HasIndex(x => new { x.ComprehensiveAssessmentResultId, x.ComprehensiveAssessmentDimensionId }).IsUnique(); + entity.HasOne(x => x.Result).WithMany(x => x.Details) + .HasForeignKey(x => x.ComprehensiveAssessmentResultId).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(x => x.Dimension).WithMany().HasForeignKey(x => x.ComprehensiveAssessmentDimensionId) + .OnDelete(DeleteBehavior.Restrict); + }); + builder.Entity(entity => + { + entity.Property(x => x.Reason).HasMaxLength(1000); + entity.Property(x => x.ReviewComment).HasMaxLength(500); + entity.HasIndex(x => new { x.ComprehensiveAssessmentBatchId, x.StudentId, x.Status }); + entity.HasOne(x => x.Batch).WithMany().HasForeignKey(x => x.ComprehensiveAssessmentBatchId) + .OnDelete(DeleteBehavior.Cascade); + entity.HasOne(x => x.Student).WithMany().HasForeignKey(x => x.StudentId) + .OnDelete(DeleteBehavior.Restrict); + entity.HasOne(x => x.ResultDetail).WithMany().HasForeignKey(x => x.ComprehensiveAssessmentResultDetailId) + .OnDelete(DeleteBehavior.SetNull); + }); + builder.Entity(entity => + { + entity.Property(x => x.Note).HasMaxLength(500); + entity.HasIndex(x => new { x.ComprehensiveAssessmentBatchId, x.Version }).IsUnique(); + entity.HasOne(x => x.Batch).WithMany(x => x.Publications) + .HasForeignKey(x => x.ComprehensiveAssessmentBatchId).OnDelete(DeleteBehavior.Cascade); + entity.HasOne(x => x.PublishedByUser).WithMany().HasForeignKey(x => x.PublishedByUserId) + .OnDelete(DeleteBehavior.Restrict); + }); builder.Entity(entity => { entity.Property(x => x.Name).HasMaxLength(100); diff --git a/src/Jiaowu.Api/Infrastructure/Persistence/DatabaseInitializer.cs b/src/Jiaowu.Api/Infrastructure/Persistence/DatabaseInitializer.cs index 8f87fc0..9942c7a 100644 --- a/src/Jiaowu.Api/Infrastructure/Persistence/DatabaseInitializer.cs +++ b/src/Jiaowu.Api/Infrastructure/Persistence/DatabaseInitializer.cs @@ -77,7 +77,8 @@ public sealed class DatabaseInitializer( [SystemRoles.MaintenanceAdmin] = ("维修部门工单分派与场地状态管理", DataScope.All), [SystemRoles.MaintenanceStaff] = ("维修工单处理", DataScope.Self), [SystemRoles.PhysicalEducationAdmin] = ("全校学生体质健康测试管理", DataScope.All), - [SystemRoles.DormitoryAdmin] = ("全校宿舍档案与卫生检查管理", DataScope.All) + [SystemRoles.DormitoryAdmin] = ("全校宿舍档案与卫生检查管理", DataScope.All), + [SystemRoles.StudentAffairsAdmin] = ("全校学生综合测评管理", DataScope.All) }; foreach (var (name, definition) in roleDefinitions) diff --git a/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/20261022125028_ComprehensiveAssessments.Designer.cs b/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/20261022125028_ComprehensiveAssessments.Designer.cs new file mode 100644 index 0000000..5bf2211 --- /dev/null +++ b/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/20261022125028_ComprehensiveAssessments.Designer.cs @@ -0,0 +1,10768 @@ +// +using System; +using Jiaowu.Api.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql +{ + [DbContext(typeof(AppDbContext))] + [Migration("20261022125028_ComprehensiveAssessments")] + partial class ComprehensiveAssessments + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.13") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AcademicCalendarEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AudienceRoles") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("EndsOn") + .HasColumnType("date"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("IsOffDay") + .HasColumnType("tinyint(1)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("ReminderDays") + .HasColumnType("int"); + + b.Property("Source") + .HasColumnType("int"); + + b.Property("SourceYear") + .HasColumnType("int"); + + b.Property("StartsOn") + .HasColumnType("date"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "StartsOn"); + + b.HasIndex("IsEnabled", "StartsOn"); + + b.HasIndex("AcademicTermId", "Source", "SourceYear", "StartsOn"); + + b.ToTable("AcademicCalendarEvents"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AcademicRiskCase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AssignedCounselorUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FollowUpDueDate") + .HasColumnType("date"); + + b.Property("ReviewDate") + .HasColumnType("date"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("TaskCompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WarningRecordId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("WarningRecordId") + .IsUnique(); + + b.HasIndex("StudentId", "Status"); + + b.HasIndex("AssignedCounselorUserId", "Status", "FollowUpDueDate"); + + b.ToTable("AcademicRiskCases"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AcademicRiskCaseEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicRiskCaseId") + .HasColumnType("char(36)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("OccurredAt") + .HasColumnType("datetime(6)"); + + b.Property("RecordedByUserId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("RecordedByUserId"); + + b.HasIndex("AcademicRiskCaseId", "OccurredAt"); + + b.ToTable("AcademicRiskCaseEntries"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AcademicTerm", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicYear") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ArchiveReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ArchivedAt") + .HasColumnType("datetime(6)"); + + b.Property("ArchivedByUserId") + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndDate") + .HasColumnType("date"); + + b.Property("IsArchived") + .IsConcurrencyToken() + .HasColumnType("tinyint(1)"); + + b.Property("IsCurrent") + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Season") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("date"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("IsArchived"); + + b.HasIndex("IsCurrent"); + + b.HasIndex("IsEnabled", "SortOrder"); + + b.ToTable("AcademicTerms"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AdministrativeClass", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CounselorName") + .HasColumnType("longtext"); + + b.Property("CounselorUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Grade") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MajorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("CounselorUserId"); + + b.HasIndex("MajorId"); + + b.HasIndex("IsEnabled", "SortOrder"); + + b.ToTable("AdministrativeClasses"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ArchiveEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActorName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("ActorUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EntityId") + .HasColumnType("char(36)"); + + b.Property("IsArchived") + .HasColumnType("tinyint(1)"); + + b.Property("Kind") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Kind", "EntityId", "CreatedAt"); + + b.ToTable("ArchiveEvents"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AttendanceCheckInAttempt", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccuracyMeters") + .HasColumnType("double"); + + b.Property("AttendanceSheetId") + .HasColumnType("char(36)"); + + b.Property("CheckInMethod") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DeviceIdentifierHash") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("DevicePlatform") + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("DistanceMeters") + .HasColumnType("double"); + + b.Property("FailureCode") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("IpAddress") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("IsSuccessful") + .HasColumnType("tinyint(1)"); + + b.Property("Latitude") + .HasPrecision(10, 7) + .HasColumnType("decimal(10,7)"); + + b.Property("Longitude") + .HasPrecision(10, 7) + .HasColumnType("decimal(10,7)"); + + b.Property("RiskFlags") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("UserAgent") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.HasIndex("DeviceIdentifierHash", "CreatedAt"); + + b.HasIndex("IpAddress", "CreatedAt"); + + b.HasIndex("AttendanceSheetId", "StudentId", "CreatedAt"); + + b.ToTable("AttendanceCheckInAttempts"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AttendanceRecord", b => + { + b.Property("AttendanceSheetId") + .HasColumnType("char(36)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("AppealReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("AppealReviewComment") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("AppealReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("AppealStatus") + .HasColumnType("int"); + + b.Property("AppealSubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("CheckInAccuracyMeters") + .HasColumnType("double"); + + b.Property("CheckInAt") + .HasColumnType("datetime(6)"); + + b.Property("CheckInDistanceMeters") + .HasColumnType("double"); + + b.Property("CheckInLatitude") + .HasPrecision(10, 7) + .HasColumnType("decimal(10,7)"); + + b.Property("CheckInLongitude") + .HasPrecision(10, 7) + .HasColumnType("decimal(10,7)"); + + b.Property("CheckedInMethod") + .HasColumnType("int"); + + b.Property("Notes") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("AttendanceSheetId", "StudentId"); + + b.HasIndex("AppealStatus"); + + b.HasIndex("StudentId"); + + b.ToTable("AttendanceRecords"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AttendanceSheet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AttendanceDate") + .HasColumnType("datetime(6)"); + + b.Property("CheckInEndsAt") + .HasColumnType("datetime(6)"); + + b.Property("CheckInMethod") + .HasColumnType("int"); + + b.Property("CheckInStartsAt") + .HasColumnType("datetime(6)"); + + b.Property("CheckInToken") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("LocationRadiusMeters") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TargetLatitude") + .HasPrecision(10, 7) + .HasColumnType("decimal(10,7)"); + + b.Property("TargetLongitude") + .HasPrecision(10, 7) + .HasColumnType("decimal(10,7)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CheckInToken") + .IsUnique(); + + b.HasIndex("TeachingTaskId", "AttendanceDate"); + + b.ToTable("AttendanceSheets"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AutomaticScheduleJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActiveSchedulePlanId") + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CompletedTasks") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedEntries") + .HasColumnType("int"); + + b.Property("CurrentGeneration") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("MessagesJson") + .HasColumnType("longtext"); + + b.Property("ProcessedTasks") + .HasColumnType("int"); + + b.Property("RequestedByUserId") + .HasColumnType("char(36)"); + + b.Property("SchedulePlanId") + .HasColumnType("char(36)"); + + b.Property("StartedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalGenerations") + .HasColumnType("int"); + + b.Property("TotalTasks") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ActiveSchedulePlanId") + .IsUnique(); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("SchedulePlanId", "CreatedAt"); + + b.HasIndex("Status", "CreatedAt"); + + b.ToTable("AutomaticScheduleJobs"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Building", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CampusId") + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("IsEnabled", "SortOrder"); + + b.ToTable("Buildings"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Campus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Address") + .HasColumnType("longtext"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("IsEnabled", "SortOrder"); + + b.ToTable("Campuses"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusPaymentOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("ApplicationId") + .HasColumnType("char(36)"); + + b.Property("ConfirmedAt") + .HasColumnType("datetime(6)"); + + b.Property("ConfirmedByUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("OrderNumber") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("PaymentMethod") + .HasColumnType("int"); + + b.Property("ReferenceNumber") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId") + .IsUnique(); + + b.HasIndex("ConfirmedByUserId"); + + b.HasIndex("OrderNumber") + .IsUnique(); + + b.HasIndex("Status", "CreatedAt"); + + b.ToTable("CampusPaymentOrders"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusRegistrationApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApplicantNote") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("CancelledAt") + .HasColumnType("datetime(6)"); + + b.Property("ConfirmedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ProjectId") + .HasColumnType("char(36)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ReviewedByUserId"); + + b.HasIndex("StudentId"); + + b.HasIndex("ProjectId", "StudentId") + .IsUnique(); + + b.HasIndex("ProjectId", "Status", "CreatedAt"); + + b.ToTable("CampusRegistrationApplications"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusRegistrationProject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CollegeId") + .HasColumnType("char(36)"); + + b.Property("ContactName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ContactPhone") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserId") + .HasColumnType("char(36)"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("FeeAmount") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("RegistrationEndsAt") + .HasColumnType("datetime(6)"); + + b.Property("RegistrationStartsAt") + .HasColumnType("datetime(6)"); + + b.Property("RequiresReview") + .HasColumnType("tinyint(1)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("CollegeId", "Status", "RegistrationEndsAt"); + + b.ToTable("CampusRegistrationProjects"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusWalletAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Balance") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId") + .IsUnique(); + + b.ToTable("CampusWalletAccounts"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusWalletTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("BalanceAfter") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("OperatedByUserId") + .HasColumnType("char(36)"); + + b.Property("PaymentOrderId") + .HasColumnType("char(36)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WalletAccountId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("OperatedByUserId"); + + b.HasIndex("PaymentOrderId") + .IsUnique(); + + b.HasIndex("WalletAccountId", "CreatedAt"); + + b.ToTable("CampusWalletTransactions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Classroom", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AvailabilityStatus") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("BuildingId") + .HasColumnType("char(36)"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Equipment") + .HasColumnType("longtext"); + + b.Property("Floor") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("RoomType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("TeachingVenueNature") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("BuildingId"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("IsEnabled", "SortOrder"); + + b.ToTable("Classrooms"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ClassroomEquipment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Category") + .HasColumnType("int"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsAvailable") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ClassroomId", "IsAvailable"); + + b.ToTable("ClassroomEquipment"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ClassroomRepairTicket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AssignedAt") + .HasColumnType("datetime(6)"); + + b.Property("AssignedByUserId") + .HasColumnType("char(36)"); + + b.Property("AssignedToUserId") + .HasColumnType("char(36)"); + + b.Property("Category") + .HasColumnType("int"); + + b.Property("ClassroomEquipmentId") + .HasColumnType("char(36)"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("EscalationTeacherNotifiedAt") + .HasColumnType("datetime(6)"); + + b.Property("FaultItem") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("InitialTeacherNotifiedAt") + .HasColumnType("datetime(6)"); + + b.Property("RepairResult") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("ReporterContact") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ReporterName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ReporterUserId") + .HasColumnType("char(36)"); + + b.Property("StartedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AssignedByUserId"); + + b.HasIndex("AssignedToUserId"); + + b.HasIndex("ClassroomEquipmentId"); + + b.HasIndex("ReporterUserId"); + + b.HasIndex("ClassroomId", "Status"); + + b.HasIndex("Status", "EscalationTeacherNotifiedAt"); + + b.ToTable("ClassroomRepairTickets"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ClassroomReservation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("ApplicantCollegeId") + .HasColumnType("char(36)"); + + b.Property("ApplicantName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ApplicantUserId") + .HasColumnType("char(36)"); + + b.Property("AttendeeCount") + .HasColumnType("int"); + + b.Property("CancelledAt") + .HasColumnType("datetime(6)"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("ContactPhone") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PeriodCount") + .HasColumnType("int"); + + b.Property("Purpose") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ReservationDate") + .HasColumnType("date"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("StartPeriod") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId"); + + b.HasIndex("ReviewedByUserId"); + + b.HasIndex("ApplicantCollegeId", "Status", "ReservationDate"); + + b.HasIndex("ApplicantUserId", "Status", "CreatedAt"); + + b.HasIndex("ClassroomId", "ReservationDate", "Status", "StartPeriod"); + + b.ToTable("ClassroomReservations"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.College", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CampusId") + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ShortName") + .HasColumnType("longtext"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("IsEnabled", "SortOrder"); + + b.ToTable("Colleges"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentAppeal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentBatchId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentResultDetailId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentResultDetailId"); + + b.HasIndex("StudentId"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "StudentId", "Status"); + + b.ToTable("ComprehensiveAssessmentAppeals"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AcademicYear") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CalculationError") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("CalculationStatus") + .HasColumnType("int"); + + b.Property("CollegeId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentSchemeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("PublicationCount") + .HasColumnType("int"); + + b.Property("PublicityEndsAt") + .HasColumnType("datetime(6)"); + + b.Property("PublicityStartsAt") + .HasColumnType("datetime(6)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId"); + + b.HasIndex("CollegeId"); + + b.HasIndex("ComprehensiveAssessmentSchemeId"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("AcademicYear", "CollegeId", "Status", "CreatedAt"); + + b.ToTable("ComprehensiveAssessmentBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDeclaration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApprovedScore") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ClaimedScore") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("CollegeComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("CollegeReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("CollegeReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentBatchId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentDimensionId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentRuleId") + .HasColumnType("char(36)"); + + b.Property("CounselorComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("CounselorReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("CounselorReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EvidenceDescription") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("EvidenceUrl") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("OccurredOn") + .HasColumnType("date"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentDimensionId"); + + b.HasIndex("ComprehensiveAssessmentRuleId"); + + b.HasIndex("StudentId", "OccurredOn"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "StudentId", "Status"); + + b.ToTable("ComprehensiveAssessmentDeclarations"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ComprehensiveAssessmentSchemeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsRequired") + .HasColumnType("tinyint(1)"); + + b.Property("MaxScore") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SettingsJson") + .HasColumnType("text"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("SourceType") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Weight") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentSchemeId", "Code") + .IsUnique(); + + b.ToTable("ComprehensiveAssessmentDimensions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentPublication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentBatchId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("PublishedByUserId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PublishedByUserId"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "Version") + .IsUnique(); + + b.ToTable("ComprehensiveAssessmentPublications"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ClassRank") + .HasColumnType("int"); + + b.Property("CollegeRank") + .HasColumnType("int"); + + b.Property("ComprehensiveAssessmentBatchId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("MajorRank") + .HasColumnType("int"); + + b.Property("MissingRequiredDimensionCount") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("TotalScore") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "ClassRank"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "StudentId") + .IsUnique() + .HasDatabaseName("IX_ComprehensiveAssessmentResults_ComprehensiveAssessmentBatch~1"); + + b.ToTable("ComprehensiveAssessmentResults"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResultDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentDimensionId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentResultId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Explanation") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("RawScore") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.Property("SourceSnapshotJson") + .HasColumnType("longtext"); + + b.Property("SourceStatus") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WeightedScore") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentDimensionId"); + + b.HasIndex("ComprehensiveAssessmentResultId", "ComprehensiveAssessmentDimensionId") + .IsUnique() + .HasDatabaseName("IX_ComprehensiveAssessmentResultDetails_ComprehensiveAssessmen~1"); + + b.ToTable("ComprehensiveAssessmentResultDetails"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("CategoryCap") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("ComprehensiveAssessmentDimensionId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentSchemeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Score") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentDimensionId"); + + b.HasIndex("ComprehensiveAssessmentSchemeId", "ComprehensiveAssessmentDimensionId", "Category", "Level") + .IsUnique(); + + b.ToTable("ComprehensiveAssessmentRules"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CollegeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("PublicityDays") + .HasColumnType("int"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("RankingScope") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("CollegeId", "Status", "CreatedAt"); + + b.ToTable("ComprehensiveAssessmentSchemes"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Course", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ArchiveReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ArchivedAt") + .HasColumnType("datetime(6)"); + + b.Property("ArchivedByUserId") + .HasColumnType("char(36)"); + + b.Property("AssessmentMethod") + .HasColumnType("int"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CollegeId") + .HasColumnType("char(36)"); + + b.Property("CourseCategoryId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Credits") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("EnglishName") + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("GradeEvaluationMethod") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("IsArchived") + .IsConcurrencyToken() + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LectureHours") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Nature") + .HasColumnType("int"); + + b.Property("PracticeHours") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("TotalHours") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("CourseCategoryId"); + + b.HasIndex("IsArchived"); + + b.HasIndex("CollegeId", "Nature"); + + b.HasIndex("IsEnabled", "SortOrder"); + + b.ToTable("Courses"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseAdjustment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApplicantUserId") + .HasColumnType("char(36)"); + + b.Property("CancelDate") + .HasColumnType("date"); + + b.Property("CancelWeek") + .HasColumnType("int"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .HasColumnType("int"); + + b.Property("PeriodCount") + .HasColumnType("int"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("SourceClassroomId") + .HasColumnType("char(36)"); + + b.Property("SourceDate") + .HasColumnType("date"); + + b.Property("SourcePeriodCount") + .HasColumnType("int"); + + b.Property("SourceScheduleEntryId") + .HasColumnType("char(36)"); + + b.Property("SourceStartPeriod") + .HasColumnType("int"); + + b.Property("SourceWeek") + .HasColumnType("int"); + + b.Property("StartPeriod") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("SubstituteTeacherId") + .HasColumnType("char(36)"); + + b.Property("TargetDate") + .HasColumnType("date"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicantUserId"); + + b.HasIndex("ClassroomId"); + + b.HasIndex("SubstituteTeacherId"); + + b.HasIndex("SourceScheduleEntryId", "SourceWeek"); + + b.HasIndex("Status", "CreatedAt"); + + b.HasIndex("TeachingTaskId", "Status"); + + b.ToTable("CourseAdjustments"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("IsEnabled", "SortOrder"); + + b.ToTable("CourseCategories"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseEnrollment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CourseSelectionOfferingId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EnrolledAt") + .HasColumnType("datetime(6)"); + + b.Property("EnrollmentType") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WaitlistResolutionReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("WaitlistResolvedAt") + .HasColumnType("datetime(6)"); + + b.Property("WaitlistedAt") + .HasColumnType("datetime(6)"); + + b.Property("WithdrawnAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CourseSelectionOfferingId", "StudentId") + .IsUnique(); + + b.HasIndex("StudentId", "Status"); + + b.HasIndex("CourseSelectionOfferingId", "Status", "WaitlistedAt") + .HasDatabaseName("IX_CE_Offering_Status_WaitlistedAt"); + + b.ToTable("CourseEnrollments"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseEquivalencyRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EffectiveGrade") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("MajorId") + .HasColumnType("char(36)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("OriginalCourseId") + .HasColumnType("char(36)"); + + b.Property("SubstituteCourseId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("MajorId"); + + b.HasIndex("SubstituteCourseId"); + + b.HasIndex("IsEnabled", "OriginalCourseId"); + + b.HasIndex("OriginalCourseId", "SubstituteCourseId", "MajorId", "EffectiveGrade") + .IsUnique(); + + b.ToTable("CourseEquivalencyRules"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseExemption", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("TeachingTaskId"); + + b.HasIndex("Status", "CreatedAt"); + + b.HasIndex("StudentId", "TeachingTaskId") + .IsUnique(); + + b.ToTable("CourseExemptions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseGradeStatistic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AverageScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("Below60Count") + .HasColumnType("int"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CourseId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("From60To69Count") + .HasColumnType("int"); + + b.Property("From70To79Count") + .HasColumnType("int"); + + b.Property("From80To89Count") + .HasColumnType("int"); + + b.Property("From90To100Count") + .HasColumnType("int"); + + b.Property("HighestScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("LowestScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("PassRate") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.Property("PassedCount") + .HasColumnType("int"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("ScopeEntityId") + .HasColumnType("char(36)"); + + b.Property("StudentCount") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "Scope", "ScopeEntityId"); + + b.HasIndex("CourseId", "AcademicTermId", "Scope", "ScopeEntityId") + .IsUnique() + .HasDatabaseName("UX_CourseGradeStatistics_Scope"); + + b.ToTable("CourseGradeStatistics"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseGradeStatisticsRefreshJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("GradeSheetId") + .HasColumnType("char(36)"); + + b.Property("StartedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("GradeSheetId"); + + b.HasIndex("Status", "CreatedAt"); + + b.ToTable("CourseGradeStatisticsRefreshJobs"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseGradeStatisticsRefreshSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BatchSize") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IntervalSeconds") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("LastRunAt") + .HasColumnType("datetime(6)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Key") + .IsUnique(); + + b.ToTable("CourseGradeStatisticsRefreshSettings"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("CourseGroups"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseGroupCourse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CourseGroupId") + .HasColumnType("char(36)"); + + b.Property("CourseId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("RecommendedSemester") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("CourseGroupId", "CourseId") + .IsUnique(); + + b.ToTable("CourseGroupCourses"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CoursePrerequisite", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CourseId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("PrerequisiteCourseId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("PrerequisiteCourseId"); + + b.HasIndex("CourseId", "PrerequisiteCourseId") + .IsUnique(); + + b.ToTable("CoursePrerequisites"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSelectionOffering", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("CourseSelectionRoundId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsOpenToAll") + .HasColumnType("tinyint(1)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("TeachingTaskId"); + + b.HasIndex("CourseSelectionRoundId", "TeachingTaskId") + .IsUnique(); + + b.ToTable("CourseSelectionOfferings"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSelectionRound", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndsAt") + .HasColumnType("datetime(6)"); + + b.Property("MaxCourseCount") + .HasColumnType("int"); + + b.Property("MaxCredits") + .HasPrecision(6, 1) + .HasColumnType("decimal(6,1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Scope") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("StartsAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WithdrawalEndsAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "Status"); + + b.ToTable("CourseSelectionRounds"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSelectionRoundGrade", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CourseSelectionRoundId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Grade") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Grade"); + + b.HasIndex("CourseSelectionRoundId", "Grade") + .IsUnique(); + + b.ToTable("CourseSelectionRoundGrades"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSubstitution", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CourseEquivalencyRuleId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("OriginalCourseId") + .HasColumnType("char(36)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("SubstituteCourseId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CourseEquivalencyRuleId"); + + b.HasIndex("OriginalCourseId"); + + b.HasIndex("SubstituteCourseId"); + + b.HasIndex("Status", "CreatedAt"); + + b.HasIndex("StudentId", "OriginalCourseId") + .IsUnique(); + + b.ToTable("CourseSubstitutions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CurriculumCourse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CourseId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurriculumModuleId") + .HasColumnType("char(36)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("RecommendedSemester") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("CurriculumModuleId", "CourseId") + .IsUnique(); + + b.ToTable("CurriculumCourses"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CurriculumModule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurriculumPlanId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("RequiredCredits") + .HasPrecision(6, 2) + .HasColumnType("decimal(6,2)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CurriculumPlanId", "Code") + .IsUnique(); + + b.ToTable("CurriculumModules"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CurriculumPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("EffectiveGrade") + .HasColumnType("int"); + + b.Property("MajorId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalCredits") + .HasPrecision(6, 2) + .HasColumnType("decimal(6,2)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("Status", "EffectiveGrade"); + + b.HasIndex("MajorId", "EffectiveGrade", "Version") + .IsUnique(); + + b.ToTable("CurriculumPlans"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DeferredExam", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("TeachingTaskId"); + + b.HasIndex("Status", "CreatedAt"); + + b.HasIndex("StudentId", "TeachingTaskId") + .IsUnique(); + + b.ToTable("DeferredExams"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DegreeAwardBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CalculationError") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("CalculationStatus") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DegreeName") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("EnrollmentYear") + .HasColumnType("int"); + + b.Property("GraduationYear") + .HasColumnType("int"); + + b.Property("MinimumGradePoint") + .HasPrecision(3, 2) + .HasColumnType("decimal(3,2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("GraduationYear", "Status"); + + b.ToTable("DegreeAwardBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DegreeAwardResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AverageGradePoint") + .HasPrecision(4, 2) + .HasColumnType("decimal(4,2)"); + + b.Property("CalculatedConclusion") + .HasColumnType("int"); + + b.Property("Conclusion") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DegreeAwardBatchId") + .HasColumnType("char(36)"); + + b.Property("ExceptionReason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("GraduationAuditResultId") + .HasColumnType("char(36)"); + + b.Property("IsOverridden") + .HasColumnType("tinyint(1)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("GraduationAuditResultId"); + + b.HasIndex("StudentId"); + + b.HasIndex("Conclusion", "IsOverridden"); + + b.HasIndex("DegreeAwardBatchId", "StudentId") + .IsUnique(); + + b.ToTable("DegreeAwardResults"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryAllocationBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AssignedCount") + .HasColumnType("int"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserId") + .HasColumnType("char(36)"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("Mode") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("RequestPayload") + .HasColumnType("longtext"); + + b.Property("RequestedCount") + .HasColumnType("int"); + + b.Property("ResultPayload") + .HasColumnType("longtext"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("Status", "CreatedAt"); + + b.ToTable("DormitoryAllocationBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CounselorComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("CounselorReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("CounselorReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrentBedId") + .HasColumnType("char(36)"); + + b.Property("FinalComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("FinalReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("FinalReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("PreferredBuildingId") + .HasColumnType("char(36)"); + + b.Property("PreferredRoomId") + .HasColumnType("char(36)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TargetBedId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("PreferredBuildingId"); + + b.HasIndex("PreferredRoomId"); + + b.HasIndex("Status", "SubmittedAt"); + + b.HasIndex("StudentId", "Status"); + + b.ToTable("DormitoryApplications"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryBed", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BedNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DormitoryRoomId") + .HasColumnType("char(36)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("DormitoryRoomId", "BedNumber") + .IsUnique(); + + b.ToTable("DormitoryBeds"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryBuilding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CampusId") + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("FloorCount") + .HasColumnType("int"); + + b.Property("GenderPolicy") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CampusId"); + + b.HasIndex("Code") + .IsUnique(); + + b.ToTable("DormitoryBuildings"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("InspectionDate") + .HasColumnType("date"); + + b.Property("Inspector") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("PublicationCount") + .HasColumnType("int"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Status", "InspectionDate"); + + b.ToTable("DormitoryHygieneBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneCalculation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserId") + .HasColumnType("char(36)"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("SelectedBatchCount") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentCount") + .HasColumnType("int"); + + b.Property("StudentWithoutScoreCount") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("AcademicTermId", "Status", "CreatedAt"); + + b.ToTable("DormitoryHygieneCalculations"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneCalculationBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DormitoryHygieneBatchId") + .HasColumnType("char(36)"); + + b.Property("DormitoryHygieneCalculationId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("DormitoryHygieneBatchId"); + + b.HasIndex("DormitoryHygieneCalculationId", "DormitoryHygieneBatchId") + .IsUnique(); + + b.ToTable("DormitoryHygieneCalculationBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneScore", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BeddingScore") + .HasPrecision(4, 1) + .HasColumnType("decimal(4,1)"); + + b.Property("BelongingsScore") + .HasPrecision(4, 1) + .HasColumnType("decimal(4,1)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DormitoryHygieneBatchId") + .HasColumnType("char(36)"); + + b.Property("DormitoryRoomId") + .HasColumnType("char(36)"); + + b.Property("FacilitiesScore") + .HasPrecision(4, 1) + .HasColumnType("decimal(4,1)"); + + b.Property("FloorScore") + .HasPrecision(4, 1) + .HasColumnType("decimal(4,1)"); + + b.Property("Grade") + .HasColumnType("int"); + + b.Property("IsViolation") + .HasColumnType("tinyint(1)"); + + b.Property("Issues") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("SafetyScore") + .HasPrecision(4, 1) + .HasColumnType("decimal(4,1)"); + + b.Property("TotalScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("DormitoryHygieneBatchId", "DormitoryRoomId") + .IsUnique(); + + b.HasIndex("DormitoryRoomId", "DormitoryHygieneBatchId"); + + b.ToTable("DormitoryHygieneScores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneStudentSummary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AverageScore") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DormitoryHygieneCalculationId") + .HasColumnType("char(36)"); + + b.Property("ExpectedBatchCount") + .HasColumnType("int"); + + b.Property("IncludedScoreCount") + .HasColumnType("int"); + + b.Property("MissingScoreCount") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ViolationCount") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.HasIndex("AcademicTermId", "StudentId"); + + b.HasIndex("DormitoryHygieneCalculationId", "StudentId") + .IsUnique(); + + b.ToTable("DormitoryHygieneStudentSummaries"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryOccupancy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CheckInDate") + .HasColumnType("date"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DormitoryBedId") + .HasColumnType("char(36)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("DormitoryBedId") + .IsUnique(); + + b.HasIndex("StudentId") + .IsUnique(); + + b.ToTable("DormitoryOccupancies"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryRoom", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DormitoryBuildingId") + .HasColumnType("char(36)"); + + b.Property("Floor") + .HasColumnType("int"); + + b.Property("GenderPolicy") + .HasColumnType("int"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("RoomNumber") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("DormitoryBuildingId", "RoomNumber") + .IsUnique(); + + b.ToTable("DormitoryRooms"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryStayHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Action") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DormitoryAllocationBatchId") + .HasColumnType("char(36)"); + + b.Property("DormitoryApplicationId") + .HasColumnType("char(36)"); + + b.Property("EffectiveDate") + .HasColumnType("date"); + + b.Property("FromBedId") + .HasColumnType("char(36)"); + + b.Property("OccurredAt") + .HasColumnType("datetime(6)"); + + b.Property("OperatedByUserId") + .HasColumnType("char(36)"); + + b.Property("Reason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("ToBedId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("DormitoryAllocationBatchId"); + + b.HasIndex("FromBedId"); + + b.HasIndex("ToBedId"); + + b.HasIndex("StudentId", "EffectiveDate"); + + b.HasIndex("StudentId", "OccurredAt"); + + b.ToTable("DormitoryStayHistories"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationDimension", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EvaluationSetupId") + .HasColumnType("char(36)"); + + b.Property("MaxScore") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("EvaluationSetupId", "SortOrder"); + + b.ToTable("EvaluationDimensions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EvaluationSetupId") + .HasColumnType("char(36)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.HasIndex("TeachingTaskId"); + + b.HasIndex("EvaluationSetupId", "StudentId", "TeachingTaskId") + .IsUnique(); + + b.ToTable("EvaluationRecords"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationScore", b => + { + b.Property("EvaluationRecordId") + .HasColumnType("char(36)"); + + b.Property("EvaluationDimensionId") + .HasColumnType("char(36)"); + + b.Property("Score") + .HasColumnType("int"); + + b.HasKey("EvaluationRecordId", "EvaluationDimensionId"); + + b.HasIndex("EvaluationDimensionId"); + + b.ToTable("EvaluationScores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationSetup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndsAt") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("StartsAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "Status"); + + b.ToTable("EvaluationSetups"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamArrangementJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivePlanId") + .HasColumnType("char(36)"); + + b.Property("AssignClassrooms") + .HasColumnType("tinyint(1)"); + + b.Property("AssignInvigilators") + .HasColumnType("tinyint(1)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrentStep") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("PlanId") + .HasColumnType("char(36)"); + + b.Property("ProcessedSessions") + .HasColumnType("int"); + + b.Property("ProjectIdsJson") + .HasColumnType("longtext"); + + b.Property("RequestedByUserId") + .HasColumnType("char(36)"); + + b.Property("ResultMessage") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("SessionIdsJson") + .HasColumnType("longtext"); + + b.Property("StartedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalSessions") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("Kind", "ActivePlanId") + .IsUnique() + .HasDatabaseName("UX_ExamArrangementJobs_Kind_ActivePlan"); + + b.HasIndex("Status", "CreatedAt"); + + b.HasIndex("Kind", "PlanId", "CreatedAt") + .HasDatabaseName("IX_ExamArrangementJobs_Kind_Plan_CreatedAt"); + + b.ToTable("ExamArrangementJobs"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "Status"); + + b.ToTable("ExamPlans"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamPublishJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivePlanId") + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrentStep") + .HasColumnType("longtext"); + + b.Property("ErrorMessage") + .HasColumnType("longtext"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("PlanId") + .HasColumnType("char(36)"); + + b.Property("ProjectIdsJson") + .HasColumnType("longtext"); + + b.Property("RequestedByUserId") + .HasColumnType("char(36)"); + + b.Property("StartedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.ToTable("ExamPublishJobs"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamRoomAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("CourseId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndsAt") + .HasColumnType("datetime(6)"); + + b.Property("ExamDate") + .HasColumnType("date"); + + b.Property("ExamPlanId") + .HasColumnType("char(36)"); + + b.Property("PeriodCount") + .HasColumnType("int"); + + b.Property("RequiredInvigilatorCount") + .HasColumnType("int"); + + b.Property("StartPeriod") + .HasColumnType("int"); + + b.Property("StartsAt") + .HasColumnType("datetime(6)"); + + b.Property("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("ExamRoomId") + .HasColumnType("char(36)"); + + b.Property("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("ExamRoomId") + .HasColumnType("char(36)"); + + b.Property("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("ExamRoomId") + .HasColumnType("char(36)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("ExamSessionId") + .HasColumnType("char(36)"); + + b.Property("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("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndsAt") + .HasColumnType("datetime(6)"); + + b.Property("ExamDate") + .HasColumnType("date"); + + b.Property("ExamPlanId") + .HasColumnType("char(36)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PeriodCount") + .HasColumnType("int"); + + b.Property("RequiredBuildingId") + .HasColumnType("char(36)"); + + b.Property("RequiredBuildingIds") + .HasColumnType("longtext"); + + b.Property("RequiredInvigilatorCount") + .HasColumnType("int"); + + b.Property("StartPeriod") + .HasColumnType("int"); + + b.Property("StartsAt") + .HasColumnType("datetime(6)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ClassroomId"); + + b.HasIndex("RequiredBuildingId"); + + b.HasIndex("TeachingTaskId"); + + b.HasIndex("ExamPlanId", "ExamDate"); + + b.HasIndex("ExamPlanId", "StartsAt"); + + b.ToTable("ExamSessions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamSessionInvigilator", b => + { + b.Property("ExamSessionId") + .HasColumnType("char(36)"); + + b.Property("TeacherId") + .HasColumnType("char(36)"); + + b.HasKey("ExamSessionId", "TeacherId"); + + b.HasIndex("TeacherId"); + + b.ToTable("ExamSessionInvigilators"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamSignInExportJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrentStep") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("FileBytes") + .HasColumnType("longblob"); + + b.Property("FileName") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("FileSize") + .HasColumnType("int"); + + b.Property("PlanId") + .HasColumnType("char(36)"); + + b.Property("RequestedByUserId") + .HasColumnType("char(36)"); + + b.Property("StartedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("PlanId", "CreatedAt"); + + b.HasIndex("Status", "CreatedAt"); + + b.ToTable("ExamSignInExportJobs"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentBooking", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BookedAt") + .HasColumnType("datetime(6)"); + + b.Property("CancelledAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExperimentProjectId") + .HasColumnType("char(36)"); + + b.Property("ExperimentSessionId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.HasIndex("ExperimentProjectId", "StudentId") + .IsUnique(); + + b.HasIndex("ExperimentSessionId", "Status", "BookedAt"); + + b.ToTable("ExperimentBookings"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentCourseGrade", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("PublishedProjectCount") + .HasColumnType("int"); + + b.Property("RefreshedAt") + .HasColumnType("datetime(6)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("TotalWeight") + .HasPrecision(8, 1) + .HasColumnType("decimal(8,1)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WeightedAverageScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.HasIndex("TeachingTaskId", "StudentId") + .IsUnique(); + + b.ToTable("ExperimentCourseGrades"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExperimentGradeSheetId") + .HasColumnType("char(36)"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Weight") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.HasKey("Id"); + + b.HasIndex("ExperimentGradeSheetId", "SortOrder"); + + b.ToTable("ExperimentGradeItems"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeItemScore", b => + { + b.Property("ExperimentGradeRecordId") + .HasColumnType("char(36)"); + + b.Property("ExperimentGradeItemId") + .HasColumnType("char(36)"); + + b.Property("Comment") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Score") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.HasKey("ExperimentGradeRecordId", "ExperimentGradeItemId"); + + b.HasIndex("ExperimentGradeItemId"); + + b.ToTable("ExperimentGradeItemScores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AttemptNumber") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExperimentGradeSheetId") + .HasColumnType("char(36)"); + + b.Property("ExperimentSessionId") + .HasColumnType("char(36)"); + + b.Property("IsLate") + .HasColumnType("tinyint(1)"); + + b.Property("IsPassed") + .HasColumnType("tinyint(1)"); + + b.Property("ParticipationStatus") + .HasColumnType("int"); + + b.Property("SafetyViolation") + .HasColumnType("tinyint(1)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("SubmissionReference") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TeacherComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("TotalScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ExperimentSessionId"); + + b.HasIndex("StudentId"); + + b.HasIndex("ExperimentGradeSheetId", "StudentId") + .IsUnique(); + + b.ToTable("ExperimentGradeRecords"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeSheet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ContributionWeight") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExperimentProjectId") + .HasColumnType("char(36)"); + + b.Property("PassScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ExperimentProjectId") + .IsUnique(); + + b.ToTable("ExperimentGradeSheets"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentProject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ArrangementMode") + .HasColumnType("int"); + + b.Property("ClosedAt") + .HasColumnType("datetime(6)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("EndDate") + .HasColumnType("date"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Requirements") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("ScheduleEntryId") + .HasColumnType("char(36)"); + + b.Property("ScheduleWeek") + .HasColumnType("int"); + + b.Property("SelectionEndsAt") + .HasColumnType("datetime(6)"); + + b.Property("SelectionStartsAt") + .HasColumnType("datetime(6)"); + + b.Property("StartDate") + .HasColumnType("date"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ScheduleEntryId"); + + b.HasIndex("Status", "StartDate", "EndDate"); + + b.HasIndex("TeachingTaskId", "Code", "ScheduleEntryId", "ScheduleWeek") + .IsUnique(); + + b.ToTable("ExperimentProjects"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CancelledAt") + .HasColumnType("datetime(6)"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExperimentProjectId") + .HasColumnType("char(36)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PeriodCount") + .HasColumnType("int"); + + b.Property("ReservedCount") + .HasColumnType("int"); + + b.Property("SessionDate") + .HasColumnType("date"); + + b.Property("StartPeriod") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ExperimentProjectId", "SessionDate", "StartPeriod"); + + b.HasIndex("ClassroomId", "SessionDate", "Status", "StartPeriod"); + + b.ToTable("ExperimentSessions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentSessionInstructor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExperimentSessionId") + .HasColumnType("char(36)"); + + b.Property("TeacherId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("TeacherId"); + + b.HasIndex("ExperimentSessionId", "TeacherId") + .IsUnique(); + + b.ToTable("ExperimentSessionInstructors"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeAnalyticsComment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AuthorUserId") + .HasColumnType("char(36)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("CourseId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsAnonymous") + .HasColumnType("tinyint(1)"); + + b.Property("ParentCommentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorUserId"); + + b.HasIndex("CourseId", "CreatedAt", "Id"); + + b.HasIndex("ParentCommentId", "CreatedAt", "Id"); + + b.ToTable("GradeAnalyticsComments"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeAnalyticsCommentReaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CommentId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("CommentId", "UserId", "Type") + .IsUnique(); + + b.ToTable("GradeAnalyticsCommentReactions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("GradeSheetId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("SourceSnapshotAt") + .HasColumnType("datetime(6)"); + + b.Property("SourceType") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Weight") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.HasKey("Id"); + + b.HasIndex("GradeSheetId", "SortOrder"); + + b.ToTable("GradeItems"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeItemScore", b => + { + b.Property("GradeRecordId") + .HasColumnType("char(36)"); + + b.Property("GradeItemId") + .HasColumnType("char(36)"); + + b.Property("Score") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.HasKey("GradeRecordId", "GradeItemId"); + + b.HasIndex("GradeItemId"); + + b.ToTable("GradeItemScores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeModification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApplicantUserId") + .HasColumnType("char(36)"); + + b.Property("CollegeReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("CollegeReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrentScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("FinalReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("FinalReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("GradeRecordId") + .HasColumnType("char(36)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("RequestedScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("GradeRecordId"); + + b.HasIndex("Status", "CreatedAt"); + + b.ToTable("GradeModifications"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExamStatus") + .HasColumnType("int"); + + b.Property("FinalScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("GradePoint") + .HasPrecision(3, 1) + .HasColumnType("decimal(3,1)"); + + b.Property("GradeSheetId") + .HasColumnType("char(36)"); + + b.Property("IsPassed") + .HasColumnType("tinyint(1)"); + + b.Property("Notes") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("RegularScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("Result") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("TotalScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("GradeSheetId", "StudentId") + .IsUnique(); + + b.HasIndex("StudentId", "TotalScore"); + + b.ToTable("GradeRecords"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeSheet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ArchiveReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ArchivedAt") + .HasColumnType("datetime(6)"); + + b.Property("ArchivedByUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EvaluationMethod") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("FinalWeight") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("IsArchived") + .IsConcurrencyToken() + .HasColumnType("tinyint(1)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("RegularWeight") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("IsArchived"); + + b.HasIndex("Status"); + + b.HasIndex("TeachingTaskId") + .IsUnique(); + + b.ToTable("GradeSheets"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationAuditBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CalculationError") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("CalculationStatus") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EnrollmentYear") + .HasColumnType("int"); + + b.Property("GraduationYear") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.HasIndex("GraduationYear", "EnrollmentYear"); + + b.ToTable("GraduationAuditBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationAuditResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CalculatedConclusion") + .HasColumnType("int"); + + b.Property("Conclusion") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurriculumPlanId") + .HasColumnType("char(36)"); + + b.Property("EarnedCredits") + .HasPrecision(6, 2) + .HasColumnType("decimal(6,2)"); + + b.Property("FailedCourseCount") + .HasColumnType("int"); + + b.Property("GraduationAuditBatchId") + .HasColumnType("char(36)"); + + b.Property("IsOverridden") + .HasColumnType("tinyint(1)"); + + b.Property("MissingCourseNames") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("PassedRequiredCourseCount") + .HasColumnType("int"); + + b.Property("RequiredCourseCount") + .HasColumnType("int"); + + b.Property("RequiredCredits") + .HasPrecision(6, 2) + .HasColumnType("decimal(6,2)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("StudentStatusSnapshot") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CurriculumPlanId"); + + b.HasIndex("StudentId"); + + b.HasIndex("Conclusion", "IsOverridden"); + + b.HasIndex("GraduationAuditBatchId", "StudentId") + .IsUnique(); + + b.ToTable("GraduationAuditResults"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationClearanceBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClosedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("GraduationYear") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("GraduationYear", "Status"); + + b.ToTable("GraduationClearanceBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationClearanceItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("GraduationClearanceBatchId") + .HasColumnType("char(36)"); + + b.Property("IsRequired") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ResponsibleRole") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("ResponsibleUnit") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("GraduationClearanceBatchId", "Code") + .IsUnique(); + + b.ToTable("GraduationClearanceItems"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationClearanceRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CompletedByUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("GraduationClearanceItemId") + .HasColumnType("char(36)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("GraduationClearanceItemId", "StudentId") + .IsUnique(); + + b.HasIndex("StudentId", "Status"); + + b.ToTable("GraduationClearanceRecords"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Major", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("CollegeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DegreeType") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SchoolingYears") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("CollegeId"); + + b.HasIndex("IsEnabled", "SortOrder"); + + b.ToTable("Majors"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamAutoJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedSessions") + .HasColumnType("int"); + + b.Property("EnrolledStudents") + .HasColumnType("int"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("MakeupExamPlanId") + .HasColumnType("char(36)"); + + b.Property("MessagesJson") + .HasColumnType("longtext"); + + b.Property("ProcessedCourses") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalCourses") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("MakeupExamPlanId", "CreatedAt"); + + b.HasIndex("Status", "CreatedAt"); + + b.ToTable("MakeupExamAutoJobs"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamEnrollment", b => + { + b.Property("MakeupExamSessionId") + .HasColumnType("char(36)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("MakeupScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("Reason") + .HasColumnType("int"); + + b.Property("SourceDeferredExamId") + .HasColumnType("char(36)"); + + b.Property("SourceGradeRecordId") + .HasColumnType("char(36)"); + + b.HasKey("MakeupExamSessionId", "StudentId"); + + b.HasIndex("SourceDeferredExamId"); + + b.HasIndex("SourceGradeRecordId"); + + b.HasIndex("StudentId", "MakeupExamSessionId"); + + b.ToTable("MakeupExamEnrollments"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "Status"); + + b.ToTable("MakeupExamPlans"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndsAt") + .HasColumnType("datetime(6)"); + + b.Property("ExamDate") + .HasColumnType("date"); + + b.Property("MakeupExamPlanId") + .HasColumnType("char(36)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PeriodCount") + .HasColumnType("int"); + + b.Property("RequiredBuildingId") + .HasColumnType("char(36)"); + + b.Property("RequiredBuildingIds") + .HasColumnType("longtext"); + + b.Property("RequiredInvigilatorCount") + .HasColumnType("int"); + + b.Property("StartPeriod") + .HasColumnType("int"); + + b.Property("StartsAt") + .HasColumnType("datetime(6)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ClassroomId"); + + b.HasIndex("RequiredBuildingId"); + + b.HasIndex("TeachingTaskId"); + + b.HasIndex("MakeupExamPlanId", "ExamDate"); + + b.HasIndex("MakeupExamPlanId", "StartsAt"); + + b.ToTable("MakeupExamSessions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamSessionInvigilator", b => + { + b.Property("MakeupExamSessionId") + .HasColumnType("char(36)"); + + b.Property("TeacherId") + .HasColumnType("char(36)"); + + b.HasKey("MakeupExamSessionId", "TeacherId"); + + b.HasIndex("TeacherId"); + + b.ToTable("MakeupExamSessionInvigilators"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MessageDispatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AudienceId") + .HasColumnType("char(36)"); + + b.Property("AudienceName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("AudienceType") + .HasColumnType("int"); + + b.Property("Category") + .HasColumnType("int"); + + b.Property("Content") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("LinkUrl") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("RecipientCount") + .HasColumnType("int"); + + b.Property("SenderName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SenderUserId") + .HasColumnType("char(36)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("SenderUserId", "CreatedAt"); + + b.ToTable("MessageDispatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Category") + .HasColumnType("int"); + + b.Property("Content") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsRead") + .HasColumnType("tinyint(1)"); + + b.Property("LinkUrl") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("MessageDispatchId") + .HasColumnType("char(36)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("MessageDispatchId"); + + b.HasIndex("UserId", "CreatedAt", "Id"); + + b.HasIndex("UserId", "Category", "CreatedAt", "Id"); + + b.HasIndex("UserId", "IsRead", "CreatedAt", "Id"); + + b.ToTable("Notifications"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.OfficialDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DocumentNumber") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("InvalidatedAt") + .HasColumnType("datetime(6)"); + + b.Property("InvalidatedByUserId") + .HasColumnType("char(36)"); + + b.Property("InvalidationReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("IssuedAt") + .HasColumnType("datetime(6)"); + + b.Property("IssuedByUserId") + .HasColumnType("char(36)"); + + b.Property("PdfContent") + .IsRequired() + .HasColumnType("longblob"); + + b.Property("PdfSha256") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Purpose") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ReissuedFromDocumentId") + .HasColumnType("char(36)"); + + b.Property("SnapshotJson") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("VerificationCodeHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.HasKey("Id"); + + b.HasIndex("DocumentNumber") + .IsUnique(); + + b.HasIndex("InvalidatedByUserId"); + + b.HasIndex("IssuedByUserId"); + + b.HasIndex("ReissuedFromDocumentId") + .IsUnique(); + + b.HasIndex("VerificationCodeHash") + .IsUnique(); + + b.HasIndex("Status", "IssuedAt"); + + b.HasIndex("StudentId", "IssuedAt"); + + b.ToTable("OfficialDocuments"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.OfficialDocumentDownload", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DownloadedByUserId") + .HasColumnType("char(36)"); + + b.Property("IpAddress") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("OfficialDocumentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("UserAgent") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.HasKey("Id"); + + b.HasIndex("DownloadedByUserId", "CreatedAt"); + + b.HasIndex("OfficialDocumentId", "CreatedAt"); + + b.ToTable("OfficialDocumentDownloads"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.OtherExamBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExamCode") + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.Property("ExamDate") + .HasColumnType("date"); + + b.Property("LevelOptions") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("MaxScore") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.Property("MetricKind") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("Organizer") + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("PublicationCount") + .HasColumnType("int"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Status", "ExamDate"); + + b.ToTable("OtherExamBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.OtherExamResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AttemptNumber") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsPassed") + .HasColumnType("tinyint(1)"); + + b.Property("Level") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("OtherExamBatchId") + .HasColumnType("char(36)"); + + b.Property("Score") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId", "OtherExamBatchId"); + + b.HasIndex("OtherExamBatchId", "StudentId", "AttemptNumber") + .IsUnique(); + + b.ToTable("OtherExamResults"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.PhysicalTestBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicYear") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("PublicationCount") + .HasColumnType("int"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("StandardVersion") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TestDate") + .HasColumnType("date"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicYear", "TestDate"); + + b.ToTable("PhysicalTestBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.PhysicalTestItemResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BonusScore") + .HasPrecision(4, 1) + .HasColumnType("decimal(4,1)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ItemCode") + .HasColumnType("int"); + + b.Property("PhysicalTestRecordId") + .HasColumnType("char(36)"); + + b.Property("Score") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("Unit") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Value") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.Property("Weight") + .HasPrecision(4, 2) + .HasColumnType("decimal(4,2)"); + + b.Property("WeightedScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.HasKey("Id"); + + b.HasIndex("PhysicalTestRecordId", "ItemCode") + .IsUnique(); + + b.ToTable("PhysicalTestItemResults"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.PhysicalTestRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BonusScore") + .HasPrecision(4, 1) + .HasColumnType("decimal(4,1)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Grade") + .HasColumnType("int"); + + b.Property("GradeLevel") + .HasColumnType("int"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PhysicalTestBatchId") + .HasColumnType("char(36)"); + + b.Property("SpecialReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("StandardScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("TotalScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("PhysicalTestBatchId", "StudentId") + .IsUnique(); + + b.HasIndex("StudentId", "PhysicalTestBatchId"); + + b.ToTable("PhysicalTestRecords"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.PublishedScheduleOccurrence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .HasColumnType("int"); + + b.Property("Kind") + .HasColumnType("int"); + + b.Property("PeriodCount") + .HasColumnType("int"); + + b.Property("ScheduleEntryId") + .HasColumnType("char(36)"); + + b.Property("SchedulePlanId") + .HasColumnType("char(36)"); + + b.Property("StartPeriod") + .HasColumnType("int"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Week") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClassroomId"); + + b.HasIndex("TeachingTaskId"); + + b.HasIndex("ScheduleEntryId", "Week") + .IsUnique(); + + b.HasIndex("AcademicTermId", "TeachingTaskId", "Week"); + + b.HasIndex("AcademicTermId", "Week", "DayOfWeek", "StartPeriod", "ClassroomId"); + + b.HasIndex("SchedulePlanId", "ClassroomId", "Week", "DayOfWeek", "StartPeriod"); + + b.ToTable("PublishedScheduleOccurrences"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ScheduleEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DayOfWeek") + .HasColumnType("int"); + + b.Property("EndWeek") + .HasColumnType("int"); + + b.Property("Kind") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValue(1); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PeriodCount") + .HasColumnType("int"); + + b.Property("SchedulePlanId") + .HasColumnType("char(36)"); + + b.Property("StartPeriod") + .HasColumnType("int"); + + b.Property("StartWeek") + .HasColumnType("int"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WeekPattern") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClassroomId"); + + b.HasIndex("TeachingTaskId"); + + b.HasIndex("SchedulePlanId", "DayOfWeek", "StartPeriod"); + + b.ToTable("ScheduleEntries"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ScheduleOptimizationSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("ClassGapWeight") + .HasColumnType("int"); + + b.Property("ClassSameDayWeight") + .HasColumnType("int"); + + b.Property("ConsecutiveClassWeight") + .HasColumnType("int"); + + b.Property("CoursePreferenceWeight") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EarlyPeriodPenalty") + .HasColumnType("int"); + + b.Property("GeneticGenerationCount") + .HasColumnType("int"); + + b.Property("GeneticMutationRatePercent") + .HasColumnType("int"); + + b.Property("GeneticPopulationSize") + .HasColumnType("int"); + + b.Property("LatePeriodPenalty") + .HasColumnType("int"); + + b.Property("RoomCapacityWasteWeight") + .HasColumnType("int"); + + b.Property("TeacherSameDayWeight") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId") + .IsUnique(); + + b.ToTable("ScheduleOptimizationSettings"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.SchedulePlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "Status"); + + b.HasIndex("AcademicTermId", "Version") + .IsUnique(); + + b.ToTable("SchedulePlans"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.SchedulePublishJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("ActiveAcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CompletedSteps") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrentStep") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("RequestedByUserId") + .HasColumnType("char(36)"); + + b.Property("SchedulePlanId") + .HasColumnType("char(36)"); + + b.Property("StartedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TotalSteps") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ActiveAcademicTermId") + .IsUnique(); + + b.HasIndex("RequestedByUserId"); + + b.HasIndex("SchedulePlanId", "CreatedAt"); + + b.HasIndex("Status", "CreatedAt"); + + b.ToTable("SchedulePublishJobs"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ScheduleTimeSlot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndsAt") + .HasColumnType("time"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("PeriodNumber") + .HasColumnType("int"); + + b.Property("StartsAt") + .HasColumnType("time"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "PeriodNumber") + .IsUnique(); + + b.ToTable("ScheduleTimeSlots"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Student", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AdministrativeClassId") + .HasColumnType("char(36)"); + + b.Property("ArchiveReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ArchivedAt") + .HasColumnType("datetime(6)"); + + b.Property("ArchivedByUserId") + .HasColumnType("char(36)"); + + b.Property("Biography") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CurrentAddress") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("DateOfBirth") + .HasColumnType("date"); + + b.Property("Email") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("EmergencyContactName") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("EmergencyContactPhone") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("EmergencyContactRelationship") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("EnglishName") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("EnrollmentDate") + .HasColumnType("date"); + + b.Property("EnrollmentYear") + .HasColumnType("int"); + + b.Property("Ethnicity") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("HouseholdAddress") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("IdCardNumber") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("IsArchived") + .IsConcurrencyToken() + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Nationality") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("NativePlace") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Phone") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("PoliticalStatus") + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("PostalCode") + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Qq") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("SpecialNeeds") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("SpecialTags") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentNumber") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("WeChat") + .HasMaxLength(60) + .HasColumnType("varchar(60)"); + + b.HasKey("Id"); + + b.HasIndex("EnrollmentYear"); + + b.HasIndex("IsArchived"); + + b.HasIndex("StudentNumber") + .IsUnique(); + + b.HasIndex("UserId"); + + b.HasIndex("AdministrativeClassId", "Status"); + + b.ToTable("Students"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.StudentAcademicStatistic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AverageScore") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CourseCount") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Gpa") + .HasPrecision(4, 2) + .HasColumnType("decimal(4,2)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WeightedAverageScore") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.HasKey("Id"); + + b.HasIndex("CalculatedAt"); + + b.HasIndex("StudentId") + .IsUnique(); + + b.ToTable("StudentAcademicStatistics"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.StudentAcademicTermStatistic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AverageScore") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CourseCount") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Gpa") + .HasPrecision(4, 2) + .HasColumnType("decimal(4,2)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WeightedAverageScore") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId"); + + b.HasIndex("StudentId", "AcademicTermId") + .IsUnique(); + + b.ToTable("StudentAcademicTermStatistics"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.StudentStatusChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApprovedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("OriginalStatus") + .HasColumnType("int"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("State") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TargetStatus") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId", "State"); + + b.ToTable("StudentStatusChanges"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Teacher", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ArchiveReason") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ArchivedAt") + .HasColumnType("datetime(6)"); + + b.Property("ArchivedByUserId") + .HasColumnType("char(36)"); + + b.Property("CollegeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Email") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("HireDate") + .HasColumnType("date"); + + b.Property("IsArchived") + .IsConcurrencyToken() + .HasColumnType("tinyint(1)"); + + b.Property("IsExternal") + .HasColumnType("tinyint(1)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Phone") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TeacherNumber") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("Title") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("IsArchived"); + + b.HasIndex("TeacherNumber") + .IsUnique(); + + b.HasIndex("UserId"); + + b.HasIndex("CollegeId", "Status"); + + b.ToTable("Teachers"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeacherCourseApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CourseId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("Statement") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TeacherId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("ReviewedByUserId"); + + b.HasIndex("TeacherId"); + + b.HasIndex("Status", "AcademicTermId"); + + b.HasIndex("AcademicTermId", "TeacherId", "CourseId") + .IsUnique(); + + b.ToTable("TeacherCourseApplications"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingImprovementPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("Actions") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DueDate") + .HasColumnType("date"); + + b.Property("ProblemSummary") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TeacherId") + .HasColumnType("char(36)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("TeacherId"); + + b.HasIndex("TeachingTaskId", "TeacherId") + .IsUnique(); + + b.HasIndex("AcademicTermId", "TeacherId", "Status"); + + b.ToTable("TeachingImprovementPlans"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingImprovementReview", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Comment") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsApproved") + .HasColumnType("tinyint(1)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewerUserId") + .HasColumnType("char(36)"); + + b.Property("TeachingImprovementPlanId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("TeachingImprovementPlanId", "ReviewedAt"); + + b.ToTable("TeachingImprovementReviews"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingObservationEvaluation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EvaluatorUserId") + .HasColumnType("char(36)"); + + b.Property("Issues") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("Recommendation") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("Score") + .HasColumnType("int"); + + b.Property("Source") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("Strengths") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "TeachingTaskId", "Source"); + + b.HasIndex("TeachingTaskId", "EvaluatorUserId", "Source") + .IsUnique(); + + b.ToTable("TeachingObservationEvaluations"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTask", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("CourseId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndWeek") + .HasColumnType("int"); + + b.Property("GenerationBatchCode") + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("SchedulingMode") + .HasColumnType("int"); + + b.Property("StartWeek") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TaskNumber") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WeeklyHours") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("TaskNumber") + .IsUnique(); + + b.HasIndex("AcademicTermId", "Status"); + + b.ToTable("TeachingTasks"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskAllowedClassroom", b => + { + b.Property("TeachingTaskScheduleConstraintId") + .HasColumnType("char(36)"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.HasKey("TeachingTaskScheduleConstraintId", "ClassroomId"); + + b.HasIndex("ClassroomId"); + + b.ToTable("TeachingTaskAllowedClassrooms"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskAllowedExperimentClassroom", b => + { + b.Property("TeachingTaskScheduleConstraintId") + .HasColumnType("char(36)"); + + b.Property("ClassroomId") + .HasColumnType("char(36)"); + + b.HasKey("TeachingTaskScheduleConstraintId", "ClassroomId"); + + b.HasIndex("ClassroomId"); + + b.ToTable("TeachingTaskAllowedExperimentClassrooms"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskClass", b => + { + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("AdministrativeClassId") + .HasColumnType("char(36)"); + + b.HasKey("TeachingTaskId", "AdministrativeClassId"); + + b.HasIndex("AdministrativeClassId"); + + b.ToTable("TeachingTaskClasses"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskGradeScoreBand", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("LowerBound") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("StudentCount") + .HasColumnType("int"); + + b.Property("TeachingTaskGradeStatisticId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("UpperBound") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.HasKey("Id"); + + b.HasIndex("TeachingTaskGradeStatisticId", "SortOrder") + .IsUnique(); + + b.ToTable("TeachingTaskGradeScoreBands"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskGradeStatistic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AverageScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CourseId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExcellentCount") + .HasColumnType("int"); + + b.Property("ExcellentRate") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.Property("GradeSheetId") + .HasColumnType("char(36)"); + + b.Property("HighestScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("LowestScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("MedianScore") + .HasPrecision(5, 1) + .HasColumnType("decimal(5,1)"); + + b.Property("PassRate") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.Property("PassedCount") + .HasColumnType("int"); + + b.Property("StandardDeviation") + .HasPrecision(6, 2) + .HasColumnType("decimal(6,2)"); + + b.Property("StudentCount") + .HasColumnType("int"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId"); + + b.HasIndex("GradeSheetId") + .IsUnique(); + + b.HasIndex("TeachingTaskId") + .IsUnique(); + + b.HasIndex("CourseId", "AcademicTermId"); + + b.ToTable("TeachingTaskGradeStatistics"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskScheduleConstraint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AllowedDayOfWeeks") + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("AllowedExperimentVenueNatures") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EarliestPeriod") + .HasColumnType("int"); + + b.Property("ExperimentRequiredBuildingId") + .HasColumnType("char(36)"); + + b.Property("ExperimentRequiredCampusId") + .HasColumnType("char(36)"); + + b.Property("LatestPeriod") + .HasColumnType("int"); + + b.Property("PreferredDayOfWeeks") + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("PreferredEarliestPeriod") + .HasColumnType("int"); + + b.Property("PreferredLatestPeriod") + .HasColumnType("int"); + + b.Property("RequiredBuildingId") + .HasColumnType("char(36)"); + + b.Property("RequiredCampusId") + .HasColumnType("char(36)"); + + b.Property("RequiresClassroom") + .HasColumnType("tinyint(1)"); + + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ExperimentRequiredBuildingId"); + + b.HasIndex("ExperimentRequiredCampusId"); + + b.HasIndex("RequiredBuildingId"); + + b.HasIndex("RequiredCampusId"); + + b.HasIndex("TeachingTaskId") + .IsUnique(); + + b.ToTable("TeachingTaskScheduleConstraints"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskTeacher", b => + { + b.Property("TeachingTaskId") + .HasColumnType("char(36)"); + + b.Property("TeacherId") + .HasColumnType("char(36)"); + + b.Property("IsPrimary") + .HasColumnType("tinyint(1)"); + + b.HasKey("TeachingTaskId", "TeacherId"); + + b.HasIndex("TeacherId"); + + b.ToTable("TeachingTaskTeachers"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TuitionBill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AccommodationFee") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("AccommodationPaid") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("AdjustmentPaid") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("BasePaid") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("BaseTuition") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreditCount") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.Property("CreditFee") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("CreditPaid") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("ReconciliationAdjustment") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.HasIndex("AcademicTermId", "StudentId") + .IsUnique(); + + b.ToTable("TuitionBills"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TuitionPayment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Amount") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("ConfirmedAt") + .HasColumnType("datetime(6)"); + + b.Property("ConfirmedByUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Item") + .HasColumnType("int"); + + b.Property("Method") + .HasColumnType("int"); + + b.Property("ReferenceNumber") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TuitionBillId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("TuitionBillId", "Item", "CreatedAt"); + + b.ToTable("TuitionPayments"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TuitionTermSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreditUnitPrice") + .HasPrecision(10, 2) + .HasColumnType("decimal(10,2)"); + + b.Property("CreditsLockedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreditsLockedByUserId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId") + .IsUnique(); + + b.ToTable("TuitionTermSettings"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.VenueDisplayAnnouncement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Content") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EndsAt") + .HasColumnType("datetime(6)"); + + b.Property("IsPinned") + .HasColumnType("tinyint(1)"); + + b.Property("IsPublished") + .HasColumnType("tinyint(1)"); + + b.Property("IsUrgent") + .HasColumnType("tinyint(1)"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("Scope") + .HasColumnType("int"); + + b.Property("StartsAt") + .HasColumnType("datetime(6)"); + + b.Property("TargetId") + .HasColumnType("char(36)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("IsPublished", "StartsAt", "EndsAt"); + + b.HasIndex("Scope", "TargetId", "IsPublished"); + + b.ToTable("VenueDisplayAnnouncements"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.WarningRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AcknowledgeComment") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("AcknowledgedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Detail") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("TriggerValue") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Status"); + + b.HasIndex("StudentId", "AcademicTermId", "Type") + .IsUnique(); + + b.ToTable("WarningRecords"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.WarningRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AutoCheckEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("CheckDayOfWeek") + .HasColumnType("int"); + + b.Property("CheckHour") + .HasColumnType("int"); + + b.Property("CheckMinute") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LastCheckAt") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("NotifyCounselor") + .HasColumnType("tinyint(1)"); + + b.Property("NotifyStudent") + .HasColumnType("tinyint(1)"); + + b.Property("Threshold") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId", "Type") + .IsUnique(); + + b.ToTable("WarningRules"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("DataScope") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("CalendarSubscriptionCreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CalendarSubscriptionStamp") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("CollegeId") + .HasColumnType("char(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("longtext"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LastLoginAt") + .HasColumnType("datetime(6)"); + + b.Property("LockoutEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("LockoutEnd") + .HasColumnType("datetime"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("longtext"); + + b.Property("PhoneNumber") + .HasColumnType("longtext"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("tinyint(1)"); + + b.Property("SecurityStamp") + .HasColumnType("longtext"); + + b.Property("StaffNumber") + .HasMaxLength(30) + .HasColumnType("varchar(30)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("varchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.HasIndex("StaffNumber"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Identity.PasskeyCredential", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CredentialId") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("varchar(2048)"); + + b.Property("CredentialIdHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("FriendlyName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("IsBackedUp") + .HasColumnType("tinyint(1)"); + + b.Property("IsBackupEligible") + .HasColumnType("tinyint(1)"); + + b.Property("LastUsedAt") + .HasColumnType("datetime(6)"); + + b.Property("PublicKey") + .IsRequired() + .HasColumnType("longblob"); + + b.Property("SignatureCounter") + .HasColumnType("int unsigned"); + + b.Property("Transports") + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("CredentialIdHash") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("PasskeyCredentials"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Identity.RefreshSession", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ClientType") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime(6)"); + + b.Property("LastRefreshedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReplacedBySessionId") + .HasColumnType("char(36)"); + + b.Property("RevokedAt") + .HasColumnType("datetime(6)"); + + b.Property("SecurityStamp") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("TokenHash") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("TokenHash") + .IsUnique(); + + b.HasIndex("UserId", "ExpiresAt"); + + b.ToTable("RefreshSessions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Identity.UserNavigationPreference", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("ConfigurationJson") + .IsRequired() + .HasColumnType("text"); + + b.Property("SchemaVersion") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("UserId"); + + b.ToTable("UserNavigationPreferences"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.System.AppUpdateRelease", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("BundleContent") + .IsRequired() + .HasColumnType("longblob"); + + b.Property("Channel") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(180) + .HasColumnType("varchar(180)"); + + b.Property("FileSize") + .HasColumnType("bigint"); + + b.Property("NativeVersion") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.Property("Platform") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("PublishedByUserName") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ReleaseNotes") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("Sha256") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("Platform", "Channel", "NativeVersion", "Status"); + + b.HasIndex("Platform", "Channel", "NativeVersion", "Version") + .IsUnique(); + + b.ToTable("AppUpdateReleases"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.System.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IpAddress") + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Method") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("varchar(10)"); + + b.Property("Path") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("varchar(300)"); + + b.Property("StatusCode") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("UserName") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedAt"); + + b.ToTable("AuditLogs"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.System.BackgroundJobOutboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CompletedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("JobId") + .HasColumnType("char(36)"); + + b.Property("JobKind") + .HasColumnType("int"); + + b.Property("LastError") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("LeaseExpiresAt") + .HasColumnType("datetime(6)"); + + b.Property("ProcessingAttempts") + .HasColumnType("int"); + + b.Property("ProcessingToken") + .HasColumnType("char(36)"); + + b.Property("PublishAttempts") + .HasColumnType("int"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("State") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("LeaseExpiresAt"); + + b.HasIndex("JobKind", "JobId") + .IsUnique(); + + b.HasIndex("State", "CompletedAt"); + + b.HasIndex("State", "CreatedAt"); + + b.ToTable("BackgroundJobOutboxMessages"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.System.PluginInstallation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ChangedByUserId") + .HasMaxLength(450) + .HasColumnType("varchar(450)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("InstalledVersion") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("varchar(32)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("PluginId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("PluginId") + .IsUnique(); + + b.ToTable("PluginInstallations"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.System.PluginMigrationHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AppliedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("MigrationId") + .IsRequired() + .HasMaxLength(120) + .HasColumnType("varchar(120)"); + + b.Property("PluginId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("PluginId", "MigrationId") + .IsUnique(); + + b.ToTable("PluginMigrationHistory"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.System.PluginPackageRelease", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ActivationRequestedAt") + .HasColumnType("datetime(6)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(80) + .HasColumnType("varchar(80)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserId") + .HasMaxLength(450) + .HasColumnType("varchar(450)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("FailureMessage") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("HostApiVersion") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("ManifestJson") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(160) + .HasColumnType("varchar(160)"); + + b.Property("PackageContent") + .IsRequired() + .HasColumnType("longblob"); + + b.Property("PluginId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("PublisherId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Sha256") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("varchar(64)"); + + b.Property("Signature") + .IsRequired() + .HasColumnType("longblob"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + b.HasKey("Id"); + + b.HasIndex("PluginId", "Status"); + + b.HasIndex("PluginId", "Version") + .IsUnique(); + + b.ToTable("PluginPackageReleases"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.System.SystemFeatureSetting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsEnabled") + .HasColumnType("tinyint(1)"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("Key") + .IsUnique(); + + b.ToTable("SystemFeatureSettings"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + b.Property("ClaimType") + .HasColumnType("longtext"); + + b.Property("ClaimValue") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("ProviderKey") + .HasColumnType("varchar(255)"); + + b.Property("ProviderDisplayName") + .HasColumnType("longtext"); + + b.Property("UserId") + .HasColumnType("char(36)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("RoleId") + .HasColumnType("char(36)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("char(36)"); + + b.Property("LoginProvider") + .HasColumnType("varchar(255)"); + + b.Property("Name") + .HasColumnType("varchar(255)"); + + b.Property("Value") + .HasColumnType("longtext"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AcademicCalendarEvent", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AcademicRiskCase", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "AssignedCounselorUser") + .WithMany() + .HasForeignKey("AssignedCounselorUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.WarningRecord", "WarningRecord") + .WithOne("RiskCase") + .HasForeignKey("Jiaowu.Api.Domain.Academic.AcademicRiskCase", "WarningRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AssignedCounselorUser"); + + b.Navigation("Student"); + + b.Navigation("WarningRecord"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AcademicRiskCaseEntry", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicRiskCase", "AcademicRiskCase") + .WithMany("Entries") + .HasForeignKey("AcademicRiskCaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "RecordedByUser") + .WithMany() + .HasForeignKey("RecordedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicRiskCase"); + + b.Navigation("RecordedByUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AdministrativeClass", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "CounselorUser") + .WithMany() + .HasForeignKey("CounselorUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Major", "Major") + .WithMany() + .HasForeignKey("MajorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CounselorUser"); + + b.Navigation("Major"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AttendanceCheckInAttempt", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AttendanceSheet", "AttendanceSheet") + .WithMany("CheckInAttempts") + .HasForeignKey("AttendanceSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AttendanceSheet"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AttendanceRecord", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AttendanceSheet", "AttendanceSheet") + .WithMany("Records") + .HasForeignKey("AttendanceSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AttendanceSheet"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AttendanceSheet", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AutomaticScheduleJob", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("RequestedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.SchedulePlan", "SchedulePlan") + .WithMany() + .HasForeignKey("SchedulePlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SchedulePlan"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Building", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Campus", "Campus") + .WithMany() + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusPaymentOrder", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.CampusRegistrationApplication", "Application") + .WithOne("PaymentOrder") + .HasForeignKey("Jiaowu.Api.Domain.Academic.CampusPaymentOrder", "ApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "ConfirmedByUser") + .WithMany() + .HasForeignKey("ConfirmedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Application"); + + b.Navigation("ConfirmedByUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusRegistrationApplication", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.CampusRegistrationProject", "Project") + .WithMany("Applications") + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "ReviewedByUser") + .WithMany() + .HasForeignKey("ReviewedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Project"); + + b.Navigation("ReviewedByUser"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusRegistrationProject", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.College", "College") + .WithMany() + .HasForeignKey("CollegeId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("College"); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusWalletAccount", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusWalletTransaction", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "OperatedByUser") + .WithMany() + .HasForeignKey("OperatedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.CampusPaymentOrder", "PaymentOrder") + .WithMany() + .HasForeignKey("PaymentOrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.CampusWalletAccount", "WalletAccount") + .WithMany("Transactions") + .HasForeignKey("WalletAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OperatedByUser"); + + b.Navigation("PaymentOrder"); + + b.Navigation("WalletAccount"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Classroom", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Building", "Building") + .WithMany() + .HasForeignKey("BuildingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Building"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ClassroomEquipment", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Classroom"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ClassroomRepairTicket", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "AssignedByUser") + .WithMany() + .HasForeignKey("AssignedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "AssignedToUser") + .WithMany() + .HasForeignKey("AssignedToUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.ClassroomEquipment", "ClassroomEquipment") + .WithMany() + .HasForeignKey("ClassroomEquipmentId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "ReporterUser") + .WithMany() + .HasForeignKey("ReporterUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("AssignedByUser"); + + b.Navigation("AssignedToUser"); + + b.Navigation("Classroom"); + + b.Navigation("ClassroomEquipment"); + + b.Navigation("ReporterUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ClassroomReservation", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.College", "ApplicantCollege") + .WithMany() + .HasForeignKey("ApplicantCollegeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "ApplicantUser") + .WithMany() + .HasForeignKey("ApplicantUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "ReviewedByUser") + .WithMany() + .HasForeignKey("ReviewedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("AcademicTerm"); + + b.Navigation("ApplicantCollege"); + + b.Navigation("ApplicantUser"); + + b.Navigation("Classroom"); + + b.Navigation("ReviewedByUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.College", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Campus", "Campus") + .WithMany() + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentAppeal", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", "Batch") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResultDetail", "ResultDetail") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentResultDetailId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Batch"); + + b.Navigation("ResultDetail"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.College", "College") + .WithMany() + .HasForeignKey("CollegeId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", "Scheme") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentSchemeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("College"); + + b.Navigation("CreatedByUser"); + + b.Navigation("Scheme"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDeclaration", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", "Batch") + .WithMany("Declarations") + .HasForeignKey("ComprehensiveAssessmentBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", "Dimension") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentDimensionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentRule", "Rule") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentRuleId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Batch"); + + b.Navigation("Dimension"); + + b.Navigation("Rule"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", "Scheme") + .WithMany("Dimensions") + .HasForeignKey("ComprehensiveAssessmentSchemeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Scheme"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentPublication", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", "Batch") + .WithMany("Publications") + .HasForeignKey("ComprehensiveAssessmentBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "PublishedByUser") + .WithMany() + .HasForeignKey("PublishedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Batch"); + + b.Navigation("PublishedByUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResult", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", "Batch") + .WithMany("Results") + .HasForeignKey("ComprehensiveAssessmentBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Batch"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResultDetail", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", "Dimension") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentDimensionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResult", "Result") + .WithMany("Details") + .HasForeignKey("ComprehensiveAssessmentResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ComprehensiveAssessmentResultDetails_ComprehensiveAssessmen~1"); + + b.Navigation("Dimension"); + + b.Navigation("Result"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentRule", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", "Dimension") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentDimensionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", "Scheme") + .WithMany("Rules") + .HasForeignKey("ComprehensiveAssessmentSchemeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Dimension"); + + b.Navigation("Scheme"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.College", "College") + .WithMany() + .HasForeignKey("CollegeId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("College"); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Course", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.College", "College") + .WithMany() + .HasForeignKey("CollegeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.CourseCategory", "CourseCategory") + .WithMany() + .HasForeignKey("CourseCategoryId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("College"); + + b.Navigation("CourseCategory"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseAdjustment", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Teacher", "SubstituteTeacher") + .WithMany() + .HasForeignKey("SubstituteTeacherId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Classroom"); + + b.Navigation("SubstituteTeacher"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseEnrollment", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.CourseSelectionOffering", "CourseSelectionOffering") + .WithMany("Enrollments") + .HasForeignKey("CourseSelectionOfferingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CourseSelectionOffering"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseEquivalencyRule", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Major", "Major") + .WithMany() + .HasForeignKey("MajorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "OriginalCourse") + .WithMany() + .HasForeignKey("OriginalCourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "SubstituteCourse") + .WithMany() + .HasForeignKey("SubstituteCourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Major"); + + b.Navigation("OriginalCourse"); + + b.Navigation("SubstituteCourse"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseExemption", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Student"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseGradeStatistic", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", null) + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", null) + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseGradeStatisticsRefreshJob", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.GradeSheet", null) + .WithMany() + .HasForeignKey("GradeSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseGroupCourse", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.CourseGroup", "CourseGroup") + .WithMany("Courses") + .HasForeignKey("CourseGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Course"); + + b.Navigation("CourseGroup"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CoursePrerequisite", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "Course") + .WithMany("Prerequisites") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "PrerequisiteCourse") + .WithMany("RequiredByCourses") + .HasForeignKey("PrerequisiteCourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Course"); + + b.Navigation("PrerequisiteCourse"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSelectionOffering", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.CourseSelectionRound", "CourseSelectionRound") + .WithMany("Offerings") + .HasForeignKey("CourseSelectionRoundId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CourseSelectionRound"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSelectionRound", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSelectionRoundGrade", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.CourseSelectionRound", "CourseSelectionRound") + .WithMany("EligibleGrades") + .HasForeignKey("CourseSelectionRoundId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CourseSelectionRound"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSubstitution", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.CourseEquivalencyRule", "CourseEquivalencyRule") + .WithMany() + .HasForeignKey("CourseEquivalencyRuleId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "OriginalCourse") + .WithMany() + .HasForeignKey("OriginalCourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "SubstituteCourse") + .WithMany() + .HasForeignKey("SubstituteCourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CourseEquivalencyRule"); + + b.Navigation("OriginalCourse"); + + b.Navigation("Student"); + + b.Navigation("SubstituteCourse"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CurriculumCourse", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.CurriculumModule", "CurriculumModule") + .WithMany("Courses") + .HasForeignKey("CurriculumModuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + + b.Navigation("CurriculumModule"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CurriculumModule", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.CurriculumPlan", "CurriculumPlan") + .WithMany("Modules") + .HasForeignKey("CurriculumPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CurriculumPlan"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CurriculumPlan", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Major", "Major") + .WithMany() + .HasForeignKey("MajorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Major"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DeferredExam", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Student"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DegreeAwardResult", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.DegreeAwardBatch", "DegreeAwardBatch") + .WithMany("Results") + .HasForeignKey("DegreeAwardBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.GraduationAuditResult", "GraduationAuditResult") + .WithMany() + .HasForeignKey("GraduationAuditResultId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DegreeAwardBatch"); + + b.Navigation("GraduationAuditResult"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryAllocationBatch", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryApplication", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryBuilding", "PreferredBuilding") + .WithMany() + .HasForeignKey("PreferredBuildingId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryRoom", "PreferredRoom") + .WithMany() + .HasForeignKey("PreferredRoomId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PreferredBuilding"); + + b.Navigation("PreferredRoom"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryBed", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryRoom", "DormitoryRoom") + .WithMany("Beds") + .HasForeignKey("DormitoryRoomId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DormitoryRoom"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryBuilding", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Campus", "Campus") + .WithMany() + .HasForeignKey("CampusId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Campus"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneCalculation", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneCalculationBatch", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryHygieneBatch", "DormitoryHygieneBatch") + .WithMany() + .HasForeignKey("DormitoryHygieneBatchId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryHygieneCalculation", "DormitoryHygieneCalculation") + .WithMany("SelectedBatches") + .HasForeignKey("DormitoryHygieneCalculationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DormitoryHygieneBatch"); + + b.Navigation("DormitoryHygieneCalculation"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneScore", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryHygieneBatch", "DormitoryHygieneBatch") + .WithMany("Scores") + .HasForeignKey("DormitoryHygieneBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryRoom", "DormitoryRoom") + .WithMany("HygieneScores") + .HasForeignKey("DormitoryRoomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DormitoryHygieneBatch"); + + b.Navigation("DormitoryRoom"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneStudentSummary", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryHygieneCalculation", "DormitoryHygieneCalculation") + .WithMany("Results") + .HasForeignKey("DormitoryHygieneCalculationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("DormitoryHygieneCalculation"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryOccupancy", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryBed", "DormitoryBed") + .WithOne("Occupancy") + .HasForeignKey("Jiaowu.Api.Domain.Academic.DormitoryOccupancy", "DormitoryBedId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DormitoryBed"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryRoom", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryBuilding", "DormitoryBuilding") + .WithMany("Rooms") + .HasForeignKey("DormitoryBuildingId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DormitoryBuilding"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryStayHistory", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryAllocationBatch", "DormitoryAllocationBatch") + .WithMany() + .HasForeignKey("DormitoryAllocationBatchId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryBed", "FromBed") + .WithMany() + .HasForeignKey("FromBedId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.DormitoryBed", "ToBed") + .WithMany() + .HasForeignKey("ToBedId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("DormitoryAllocationBatch"); + + b.Navigation("FromBed"); + + b.Navigation("Student"); + + b.Navigation("ToBed"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationDimension", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.EvaluationSetup", "EvaluationSetup") + .WithMany("Dimensions") + .HasForeignKey("EvaluationSetupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EvaluationSetup"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationRecord", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.EvaluationSetup", "EvaluationSetup") + .WithMany("Records") + .HasForeignKey("EvaluationSetupId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("EvaluationSetup"); + + b.Navigation("Student"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationScore", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.EvaluationDimension", "EvaluationDimension") + .WithMany("Scores") + .HasForeignKey("EvaluationDimensionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.EvaluationRecord", "EvaluationRecord") + .WithMany("Scores") + .HasForeignKey("EvaluationRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("EvaluationDimension"); + + b.Navigation("EvaluationRecord"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationSetup", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamPlan", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.ExamPlan", "ExamPlan") + .WithMany("Sessions") + .HasForeignKey("ExamPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Building", "RequiredBuilding") + .WithMany() + .HasForeignKey("RequiredBuildingId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Classroom"); + + b.Navigation("ExamPlan"); + + b.Navigation("RequiredBuilding"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExamSessionInvigilator", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ExamSession", "ExamSession") + .WithMany("Invigilators") + .HasForeignKey("ExamSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Teacher", "Teacher") + .WithMany() + .HasForeignKey("TeacherId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ExamSession"); + + b.Navigation("Teacher"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentBooking", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentProject", "ExperimentProject") + .WithMany("Bookings") + .HasForeignKey("ExperimentProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentSession", "ExperimentSession") + .WithMany("Bookings") + .HasForeignKey("ExperimentSessionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ExperimentProject"); + + b.Navigation("ExperimentSession"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentCourseGrade", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Student"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeItem", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentGradeSheet", "ExperimentGradeSheet") + .WithMany("Items") + .HasForeignKey("ExperimentGradeSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ExperimentGradeSheet"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeItemScore", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentGradeItem", "ExperimentGradeItem") + .WithMany("Scores") + .HasForeignKey("ExperimentGradeItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentGradeRecord", "ExperimentGradeRecord") + .WithMany("ItemScores") + .HasForeignKey("ExperimentGradeRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ExperimentGradeItem"); + + b.Navigation("ExperimentGradeRecord"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeRecord", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentGradeSheet", "ExperimentGradeSheet") + .WithMany("Records") + .HasForeignKey("ExperimentGradeSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentSession", "ExperimentSession") + .WithMany() + .HasForeignKey("ExperimentSessionId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ExperimentGradeSheet"); + + b.Navigation("ExperimentSession"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeSheet", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentProject", "ExperimentProject") + .WithOne("GradeSheet") + .HasForeignKey("Jiaowu.Api.Domain.Academic.ExperimentGradeSheet", "ExperimentProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ExperimentProject"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentProject", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ScheduleEntry", "ScheduleEntry") + .WithMany() + .HasForeignKey("ScheduleEntryId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ScheduleEntry"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentSession", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentProject", "ExperimentProject") + .WithMany("Sessions") + .HasForeignKey("ExperimentProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Classroom"); + + b.Navigation("ExperimentProject"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentSessionInstructor", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ExperimentSession", "ExperimentSession") + .WithMany("Instructors") + .HasForeignKey("ExperimentSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Teacher", "Teacher") + .WithMany() + .HasForeignKey("TeacherId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ExperimentSession"); + + b.Navigation("Teacher"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeAnalyticsComment", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("AuthorUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", null) + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.GradeAnalyticsComment", null) + .WithMany() + .HasForeignKey("ParentCommentId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeAnalyticsCommentReaction", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.GradeAnalyticsComment", null) + .WithMany() + .HasForeignKey("CommentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeItem", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.GradeSheet", "GradeSheet") + .WithMany("Items") + .HasForeignKey("GradeSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GradeSheet"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeItemScore", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.GradeItem", "GradeItem") + .WithMany("Scores") + .HasForeignKey("GradeItemId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.GradeRecord", "GradeRecord") + .WithMany("ItemScores") + .HasForeignKey("GradeRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GradeItem"); + + b.Navigation("GradeRecord"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeModification", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.GradeRecord", "GradeRecord") + .WithMany() + .HasForeignKey("GradeRecordId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("GradeRecord"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeRecord", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.GradeSheet", "GradeSheet") + .WithMany("Records") + .HasForeignKey("GradeSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("GradeSheet"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeSheet", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationAuditResult", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.CurriculumPlan", "CurriculumPlan") + .WithMany() + .HasForeignKey("CurriculumPlanId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.GraduationAuditBatch", "GraduationAuditBatch") + .WithMany("Results") + .HasForeignKey("GraduationAuditBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CurriculumPlan"); + + b.Navigation("GraduationAuditBatch"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationClearanceItem", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.GraduationClearanceBatch", "GraduationClearanceBatch") + .WithMany("Items") + .HasForeignKey("GraduationClearanceBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GraduationClearanceBatch"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationClearanceRecord", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.GraduationClearanceItem", "GraduationClearanceItem") + .WithMany("Records") + .HasForeignKey("GraduationClearanceItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("GraduationClearanceItem"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Major", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.College", "College") + .WithMany() + .HasForeignKey("CollegeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("College"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamAutoJob", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.MakeupExamPlan", "MakeupExamPlan") + .WithMany() + .HasForeignKey("MakeupExamPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MakeupExamPlan"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamEnrollment", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.MakeupExamSession", "MakeupExamSession") + .WithMany("Enrollments") + .HasForeignKey("MakeupExamSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.DeferredExam", "SourceDeferredExam") + .WithMany() + .HasForeignKey("SourceDeferredExamId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.GradeRecord", "SourceGradeRecord") + .WithMany() + .HasForeignKey("SourceGradeRecordId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MakeupExamSession"); + + b.Navigation("SourceDeferredExam"); + + b.Navigation("SourceGradeRecord"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamPlan", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamSession", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.MakeupExamPlan", "MakeupExamPlan") + .WithMany("Sessions") + .HasForeignKey("MakeupExamPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Building", "RequiredBuilding") + .WithMany() + .HasForeignKey("RequiredBuildingId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Classroom"); + + b.Navigation("MakeupExamPlan"); + + b.Navigation("RequiredBuilding"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamSessionInvigilator", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.MakeupExamSession", "MakeupExamSession") + .WithMany("Invigilators") + .HasForeignKey("MakeupExamSessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Teacher", "Teacher") + .WithMany() + .HasForeignKey("TeacherId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("MakeupExamSession"); + + b.Navigation("Teacher"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Notification", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.MessageDispatch", "MessageDispatch") + .WithMany("Notifications") + .HasForeignKey("MessageDispatchId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("MessageDispatch"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.OfficialDocument", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "InvalidatedByUser") + .WithMany() + .HasForeignKey("InvalidatedByUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "IssuedByUser") + .WithMany() + .HasForeignKey("IssuedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.OfficialDocument", "ReissuedFromDocument") + .WithMany() + .HasForeignKey("ReissuedFromDocumentId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("InvalidatedByUser"); + + b.Navigation("IssuedByUser"); + + b.Navigation("ReissuedFromDocument"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.OfficialDocumentDownload", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "DownloadedByUser") + .WithMany() + .HasForeignKey("DownloadedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.OfficialDocument", "OfficialDocument") + .WithMany("Downloads") + .HasForeignKey("OfficialDocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DownloadedByUser"); + + b.Navigation("OfficialDocument"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.OtherExamResult", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.OtherExamBatch", "OtherExamBatch") + .WithMany("Results") + .HasForeignKey("OtherExamBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("OtherExamBatch"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.PhysicalTestItemResult", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.PhysicalTestRecord", "PhysicalTestRecord") + .WithMany("Items") + .HasForeignKey("PhysicalTestRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PhysicalTestRecord"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.PhysicalTestRecord", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.PhysicalTestBatch", "PhysicalTestBatch") + .WithMany("Records") + .HasForeignKey("PhysicalTestBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("PhysicalTestBatch"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.PublishedScheduleOccurrence", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.ScheduleEntry", "ScheduleEntry") + .WithMany() + .HasForeignKey("ScheduleEntryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Classroom"); + + b.Navigation("ScheduleEntry"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ScheduleEntry", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.SchedulePlan", "SchedulePlan") + .WithMany("Entries") + .HasForeignKey("SchedulePlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Classroom"); + + b.Navigation("SchedulePlan"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ScheduleOptimizationSettings", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicTerm"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.SchedulePlan", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.SchedulePublishJob", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("RequestedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.SchedulePlan", "SchedulePlan") + .WithMany() + .HasForeignKey("SchedulePlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SchedulePlan"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ScheduleTimeSlot", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicTerm"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Student", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AdministrativeClass", "AdministrativeClass") + .WithMany("Students") + .HasForeignKey("AdministrativeClassId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("AdministrativeClass"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.StudentAcademicStatistic", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.StudentAcademicTermStatistic", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.StudentStatusChange", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Teacher", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.College", "College") + .WithMany() + .HasForeignKey("CollegeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("College"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeacherCourseApplication", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("ReviewedByUserId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Teacher", "Teacher") + .WithMany() + .HasForeignKey("TeacherId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("Course"); + + b.Navigation("Teacher"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingImprovementPlan", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Teacher", "Teacher") + .WithMany() + .HasForeignKey("TeacherId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("Teacher"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingImprovementReview", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingImprovementPlan", "TeachingImprovementPlan") + .WithMany("Reviews") + .HasForeignKey("TeachingImprovementPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TeachingImprovementPlan"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingObservationEvaluation", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTask", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskAllowedClassroom", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTaskScheduleConstraint", "TeachingTaskScheduleConstraint") + .WithMany("AllowedClassrooms") + .HasForeignKey("TeachingTaskScheduleConstraintId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Classroom"); + + b.Navigation("TeachingTaskScheduleConstraint"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskAllowedExperimentClassroom", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Classroom", "Classroom") + .WithMany() + .HasForeignKey("ClassroomId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTaskScheduleConstraint", "TeachingTaskScheduleConstraint") + .WithMany("AllowedExperimentClassrooms") + .HasForeignKey("TeachingTaskScheduleConstraintId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Classroom"); + + b.Navigation("TeachingTaskScheduleConstraint"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskClass", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AdministrativeClass", "AdministrativeClass") + .WithMany() + .HasForeignKey("AdministrativeClassId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany("Classes") + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AdministrativeClass"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskGradeScoreBand", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTaskGradeStatistic", "TeachingTaskGradeStatistic") + .WithMany("ScoreBands") + .HasForeignKey("TeachingTaskGradeStatisticId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TeachingTaskGradeStatistic"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskGradeStatistic", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", null) + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Course", null) + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.GradeSheet", "GradeSheet") + .WithOne() + .HasForeignKey("Jiaowu.Api.Domain.Academic.TeachingTaskGradeStatistic", "GradeSheetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithOne() + .HasForeignKey("Jiaowu.Api.Domain.Academic.TeachingTaskGradeStatistic", "TeachingTaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GradeSheet"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskScheduleConstraint", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Building", "ExperimentRequiredBuilding") + .WithMany() + .HasForeignKey("ExperimentRequiredBuildingId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.Campus", "ExperimentRequiredCampus") + .WithMany() + .HasForeignKey("ExperimentRequiredCampusId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.Building", "RequiredBuilding") + .WithMany() + .HasForeignKey("RequiredBuildingId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.Campus", "RequiredCampus") + .WithMany() + .HasForeignKey("RequiredCampusId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany() + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ExperimentRequiredBuilding"); + + b.Navigation("ExperimentRequiredCampus"); + + b.Navigation("RequiredBuilding"); + + b.Navigation("RequiredCampus"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskTeacher", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Teacher", "Teacher") + .WithMany() + .HasForeignKey("TeacherId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.TeachingTask", "TeachingTask") + .WithMany("Teachers") + .HasForeignKey("TeachingTaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Teacher"); + + b.Navigation("TeachingTask"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TuitionBill", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TuitionPayment", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.TuitionBill", "TuitionBill") + .WithMany("Payments") + .HasForeignKey("TuitionBillId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TuitionBill"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TuitionTermSetting", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.WarningRecord", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.WarningRule", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicTerm"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Identity.PasskeyCredential", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Identity.RefreshSession", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Identity.UserNavigationPreference", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "User") + .WithOne() + .HasForeignKey("Jiaowu.Api.Domain.Identity.UserNavigationPreference", "UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AcademicRiskCase", b => + { + b.Navigation("Entries"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AdministrativeClass", b => + { + b.Navigation("Students"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.AttendanceSheet", b => + { + b.Navigation("CheckInAttempts"); + + b.Navigation("Records"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusRegistrationApplication", b => + { + b.Navigation("PaymentOrder"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusRegistrationProject", b => + { + b.Navigation("Applications"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CampusWalletAccount", b => + { + b.Navigation("Transactions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", b => + { + b.Navigation("Declarations"); + + b.Navigation("Publications"); + + b.Navigation("Results"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResult", b => + { + b.Navigation("Details"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", b => + { + b.Navigation("Dimensions"); + + b.Navigation("Rules"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Course", b => + { + b.Navigation("Prerequisites"); + + b.Navigation("RequiredByCourses"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseGroup", b => + { + b.Navigation("Courses"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSelectionOffering", b => + { + b.Navigation("Enrollments"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CourseSelectionRound", b => + { + b.Navigation("EligibleGrades"); + + b.Navigation("Offerings"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CurriculumModule", b => + { + b.Navigation("Courses"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.CurriculumPlan", b => + { + b.Navigation("Modules"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DegreeAwardBatch", b => + { + b.Navigation("Results"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryBed", b => + { + b.Navigation("Occupancy"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryBuilding", b => + { + b.Navigation("Rooms"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneBatch", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryHygieneCalculation", b => + { + b.Navigation("Results"); + + b.Navigation("SelectedBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.DormitoryRoom", b => + { + b.Navigation("Beds"); + + b.Navigation("HygieneScores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationDimension", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationRecord", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.EvaluationSetup", b => + { + b.Navigation("Dimensions"); + + b.Navigation("Records"); + }); + + 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.ExperimentGradeItem", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeRecord", b => + { + b.Navigation("ItemScores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentGradeSheet", b => + { + b.Navigation("Items"); + + b.Navigation("Records"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentProject", b => + { + b.Navigation("Bookings"); + + b.Navigation("GradeSheet"); + + b.Navigation("Sessions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ExperimentSession", b => + { + b.Navigation("Bookings"); + + b.Navigation("Instructors"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeItem", b => + { + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeRecord", b => + { + b.Navigation("ItemScores"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GradeSheet", b => + { + b.Navigation("Items"); + + b.Navigation("Records"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationAuditBatch", b => + { + b.Navigation("Results"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationClearanceBatch", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.GraduationClearanceItem", b => + { + b.Navigation("Records"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamPlan", b => + { + b.Navigation("Sessions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MakeupExamSession", b => + { + b.Navigation("Enrollments"); + + b.Navigation("Invigilators"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.MessageDispatch", b => + { + b.Navigation("Notifications"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.OfficialDocument", b => + { + b.Navigation("Downloads"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.OtherExamBatch", b => + { + b.Navigation("Results"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.PhysicalTestBatch", b => + { + b.Navigation("Records"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.PhysicalTestRecord", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.SchedulePlan", b => + { + b.Navigation("Entries"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingImprovementPlan", b => + { + b.Navigation("Reviews"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTask", b => + { + b.Navigation("Classes"); + + b.Navigation("Teachers"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskGradeStatistic", b => + { + b.Navigation("ScoreBands"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TeachingTaskScheduleConstraint", b => + { + b.Navigation("AllowedClassrooms"); + + b.Navigation("AllowedExperimentClassrooms"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.TuitionBill", b => + { + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.WarningRecord", b => + { + b.Navigation("RiskCase"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/20261022125028_ComprehensiveAssessments.cs b/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/20261022125028_ComprehensiveAssessments.cs new file mode 100644 index 0000000..9cfdc4f --- /dev/null +++ b/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/20261022125028_ComprehensiveAssessments.cs @@ -0,0 +1,518 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql +{ + /// + public partial class ComprehensiveAssessments : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ComprehensiveAssessmentSchemes", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + Name = table.Column(type: "varchar(150)", maxLength: 150, nullable: false), + Version = table.Column(type: "int", nullable: false), + CollegeId = table.Column(type: "char(36)", nullable: true), + Status = table.Column(type: "int", nullable: false), + RankingScope = table.Column(type: "int", nullable: false), + PublicityDays = table.Column(type: "int", nullable: false), + Notes = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true), + CreatedByUserId = table.Column(type: "char(36)", nullable: false), + PublishedAt = table.Column(type: "datetime(6)", nullable: true), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ComprehensiveAssessmentSchemes", x => x.Id); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentSchemes_AspNetUsers_CreatedByUserId", + column: x => x.CreatedByUserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentSchemes_Colleges_CollegeId", + column: x => x.CollegeId, + principalTable: "Colleges", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySQL:Charset", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ComprehensiveAssessmentBatches", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentSchemeId = table.Column(type: "char(36)", nullable: false), + Name = table.Column(type: "varchar(150)", maxLength: 150, nullable: false), + AcademicYear = table.Column(type: "varchar(20)", maxLength: 20, nullable: false), + AcademicTermId = table.Column(type: "char(36)", nullable: true), + CollegeId = table.Column(type: "char(36)", nullable: true), + Status = table.Column(type: "int", nullable: false), + CalculationStatus = table.Column(type: "int", nullable: false), + CalculationError = table.Column(type: "varchar(2000)", maxLength: 2000, nullable: true), + CalculatedAt = table.Column(type: "datetime(6)", nullable: true), + PublicityStartsAt = table.Column(type: "datetime(6)", nullable: true), + PublicityEndsAt = table.Column(type: "datetime(6)", nullable: true), + PublishedAt = table.Column(type: "datetime(6)", nullable: true), + PublicationCount = table.Column(type: "int", nullable: false), + Notes = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true), + CreatedByUserId = table.Column(type: "char(36)", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ComprehensiveAssessmentBatches", x => x.Id); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentBatches_AcademicTerms_AcademicTermId", + column: x => x.AcademicTermId, + principalTable: "AcademicTerms", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentBatches_AspNetUsers_CreatedByUserId", + column: x => x.CreatedByUserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentBatches_Colleges_CollegeId", + column: x => x.CollegeId, + principalTable: "Colleges", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentBatches_ComprehensiveAssessmentScheme~", + column: x => x.ComprehensiveAssessmentSchemeId, + principalTable: "ComprehensiveAssessmentSchemes", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySQL:Charset", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ComprehensiveAssessmentDimensions", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentSchemeId = table.Column(type: "char(36)", nullable: false), + Code = table.Column(type: "varchar(50)", maxLength: 50, nullable: false), + Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false), + SourceType = table.Column(type: "int", nullable: false), + Weight = table.Column(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false), + MaxScore = table.Column(type: "decimal(7,2)", precision: 7, scale: 2, nullable: false), + SortOrder = table.Column(type: "int", nullable: false), + IsRequired = table.Column(type: "tinyint(1)", nullable: false), + SettingsJson = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ComprehensiveAssessmentDimensions", x => x.Id); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentDimensions_ComprehensiveAssessmentSch~", + column: x => x.ComprehensiveAssessmentSchemeId, + principalTable: "ComprehensiveAssessmentSchemes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySQL:Charset", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ComprehensiveAssessmentPublications", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentBatchId = table.Column(type: "char(36)", nullable: false), + Version = table.Column(type: "int", nullable: false), + Type = table.Column(type: "int", nullable: false), + PublishedByUserId = table.Column(type: "char(36)", nullable: false), + PublishedAt = table.Column(type: "datetime(6)", nullable: false), + Note = table.Column(type: "varchar(500)", maxLength: 500, nullable: true), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ComprehensiveAssessmentPublications", x => x.Id); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentPublications_AspNetUsers_PublishedByU~", + column: x => x.PublishedByUserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentPublications_ComprehensiveAssessmentB~", + column: x => x.ComprehensiveAssessmentBatchId, + principalTable: "ComprehensiveAssessmentBatches", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySQL:Charset", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ComprehensiveAssessmentResults", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentBatchId = table.Column(type: "char(36)", nullable: false), + StudentId = table.Column(type: "char(36)", nullable: false), + TotalScore = table.Column(type: "decimal(8,2)", precision: 8, scale: 2, nullable: false), + ClassRank = table.Column(type: "int", nullable: true), + MajorRank = table.Column(type: "int", nullable: true), + CollegeRank = table.Column(type: "int", nullable: true), + MissingRequiredDimensionCount = table.Column(type: "int", nullable: false), + CalculatedAt = table.Column(type: "datetime(6)", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ComprehensiveAssessmentResults", x => x.Id); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentResults_ComprehensiveAssessmentBatche~", + column: x => x.ComprehensiveAssessmentBatchId, + principalTable: "ComprehensiveAssessmentBatches", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentResults_Students_StudentId", + column: x => x.StudentId, + principalTable: "Students", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySQL:Charset", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ComprehensiveAssessmentRules", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentSchemeId = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentDimensionId = table.Column(type: "char(36)", nullable: false), + Category = table.Column(type: "varchar(100)", maxLength: 100, nullable: false), + Level = table.Column(type: "varchar(100)", maxLength: 100, nullable: false), + Score = table.Column(type: "decimal(7,2)", precision: 7, scale: 2, nullable: false), + CategoryCap = table.Column(type: "decimal(7,2)", precision: 7, scale: 2, nullable: true), + SortOrder = table.Column(type: "int", nullable: false), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ComprehensiveAssessmentRules", x => x.Id); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentRules_ComprehensiveAssessmentDimensio~", + column: x => x.ComprehensiveAssessmentDimensionId, + principalTable: "ComprehensiveAssessmentDimensions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentRules_ComprehensiveAssessmentSchemes_~", + column: x => x.ComprehensiveAssessmentSchemeId, + principalTable: "ComprehensiveAssessmentSchemes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySQL:Charset", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ComprehensiveAssessmentResultDetails", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentResultId = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentDimensionId = table.Column(type: "char(36)", nullable: false), + SourceStatus = table.Column(type: "int", nullable: false), + RawScore = table.Column(type: "decimal(8,2)", precision: 8, scale: 2, nullable: true), + WeightedScore = table.Column(type: "decimal(8,2)", precision: 8, scale: 2, nullable: false), + Explanation = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true), + SourceSnapshotJson = table.Column(type: "longtext", nullable: true), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ComprehensiveAssessmentResultDetails", x => x.Id); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentResultDetails_ComprehensiveAssessment~", + column: x => x.ComprehensiveAssessmentDimensionId, + principalTable: "ComprehensiveAssessmentDimensions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentResultDetails_ComprehensiveAssessmen~1", + column: x => x.ComprehensiveAssessmentResultId, + principalTable: "ComprehensiveAssessmentResults", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySQL:Charset", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ComprehensiveAssessmentDeclarations", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentBatchId = table.Column(type: "char(36)", nullable: false), + StudentId = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentDimensionId = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentRuleId = table.Column(type: "char(36)", nullable: true), + Title = table.Column(type: "varchar(200)", maxLength: 200, nullable: false), + Category = table.Column(type: "varchar(100)", maxLength: 100, nullable: false), + Level = table.Column(type: "varchar(100)", maxLength: 100, nullable: false), + OccurredOn = table.Column(type: "date", nullable: false), + EvidenceDescription = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: true), + EvidenceUrl = table.Column(type: "varchar(500)", maxLength: 500, nullable: true), + ClaimedScore = table.Column(type: "decimal(7,2)", precision: 7, scale: 2, nullable: false), + ApprovedScore = table.Column(type: "decimal(7,2)", precision: 7, scale: 2, nullable: true), + Status = table.Column(type: "int", nullable: false), + SubmittedAt = table.Column(type: "datetime(6)", nullable: true), + CounselorReviewedByUserId = table.Column(type: "char(36)", nullable: true), + CounselorReviewedAt = table.Column(type: "datetime(6)", nullable: true), + CounselorComment = table.Column(type: "varchar(500)", maxLength: 500, nullable: true), + CollegeReviewedByUserId = table.Column(type: "char(36)", nullable: true), + CollegeReviewedAt = table.Column(type: "datetime(6)", nullable: true), + CollegeComment = table.Column(type: "varchar(500)", maxLength: 500, nullable: true), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ComprehensiveAssessmentDeclarations", x => x.Id); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentDeclarations_ComprehensiveAssessmentB~", + column: x => x.ComprehensiveAssessmentBatchId, + principalTable: "ComprehensiveAssessmentBatches", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentDeclarations_ComprehensiveAssessmentD~", + column: x => x.ComprehensiveAssessmentDimensionId, + principalTable: "ComprehensiveAssessmentDimensions", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentDeclarations_ComprehensiveAssessmentR~", + column: x => x.ComprehensiveAssessmentRuleId, + principalTable: "ComprehensiveAssessmentRules", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentDeclarations_Students_StudentId", + column: x => x.StudentId, + principalTable: "Students", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySQL:Charset", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ComprehensiveAssessmentAppeals", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentBatchId = table.Column(type: "char(36)", nullable: false), + StudentId = table.Column(type: "char(36)", nullable: false), + ComprehensiveAssessmentResultDetailId = table.Column(type: "char(36)", nullable: true), + Reason = table.Column(type: "varchar(1000)", maxLength: 1000, nullable: false), + Status = table.Column(type: "int", nullable: false), + ReviewComment = table.Column(type: "varchar(500)", maxLength: 500, nullable: true), + ReviewedByUserId = table.Column(type: "char(36)", nullable: true), + ReviewedAt = table.Column(type: "datetime(6)", nullable: true), + CreatedAt = table.Column(type: "datetime(6)", nullable: false), + UpdatedAt = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ComprehensiveAssessmentAppeals", x => x.Id); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentAppeals_ComprehensiveAssessmentBatche~", + column: x => x.ComprehensiveAssessmentBatchId, + principalTable: "ComprehensiveAssessmentBatches", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentAppeals_ComprehensiveAssessmentResult~", + column: x => x.ComprehensiveAssessmentResultDetailId, + principalTable: "ComprehensiveAssessmentResultDetails", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + table.ForeignKey( + name: "FK_ComprehensiveAssessmentAppeals_Students_StudentId", + column: x => x.StudentId, + principalTable: "Students", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySQL:Charset", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentAppeals_ComprehensiveAssessmentBatchI~", + table: "ComprehensiveAssessmentAppeals", + columns: new[] { "ComprehensiveAssessmentBatchId", "StudentId", "Status" }); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentAppeals_ComprehensiveAssessmentResult~", + table: "ComprehensiveAssessmentAppeals", + column: "ComprehensiveAssessmentResultDetailId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentAppeals_StudentId", + table: "ComprehensiveAssessmentAppeals", + column: "StudentId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentBatches_AcademicTermId", + table: "ComprehensiveAssessmentBatches", + column: "AcademicTermId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentBatches_AcademicYear_CollegeId_Status~", + table: "ComprehensiveAssessmentBatches", + columns: new[] { "AcademicYear", "CollegeId", "Status", "CreatedAt" }); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentBatches_CollegeId", + table: "ComprehensiveAssessmentBatches", + column: "CollegeId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentBatches_ComprehensiveAssessmentScheme~", + table: "ComprehensiveAssessmentBatches", + column: "ComprehensiveAssessmentSchemeId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentBatches_CreatedByUserId", + table: "ComprehensiveAssessmentBatches", + column: "CreatedByUserId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentDeclarations_ComprehensiveAssessmentB~", + table: "ComprehensiveAssessmentDeclarations", + columns: new[] { "ComprehensiveAssessmentBatchId", "StudentId", "Status" }); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentDeclarations_ComprehensiveAssessmentD~", + table: "ComprehensiveAssessmentDeclarations", + column: "ComprehensiveAssessmentDimensionId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentDeclarations_ComprehensiveAssessmentR~", + table: "ComprehensiveAssessmentDeclarations", + column: "ComprehensiveAssessmentRuleId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentDeclarations_StudentId_OccurredOn", + table: "ComprehensiveAssessmentDeclarations", + columns: new[] { "StudentId", "OccurredOn" }); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentDimensions_ComprehensiveAssessmentSch~", + table: "ComprehensiveAssessmentDimensions", + columns: new[] { "ComprehensiveAssessmentSchemeId", "Code" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentPublications_ComprehensiveAssessmentB~", + table: "ComprehensiveAssessmentPublications", + columns: new[] { "ComprehensiveAssessmentBatchId", "Version" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentPublications_PublishedByUserId", + table: "ComprehensiveAssessmentPublications", + column: "PublishedByUserId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentResultDetails_ComprehensiveAssessmen~1", + table: "ComprehensiveAssessmentResultDetails", + columns: new[] { "ComprehensiveAssessmentResultId", "ComprehensiveAssessmentDimensionId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentResultDetails_ComprehensiveAssessment~", + table: "ComprehensiveAssessmentResultDetails", + column: "ComprehensiveAssessmentDimensionId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentResults_ComprehensiveAssessmentBatch~1", + table: "ComprehensiveAssessmentResults", + columns: new[] { "ComprehensiveAssessmentBatchId", "StudentId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentResults_ComprehensiveAssessmentBatchI~", + table: "ComprehensiveAssessmentResults", + columns: new[] { "ComprehensiveAssessmentBatchId", "ClassRank" }); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentResults_StudentId", + table: "ComprehensiveAssessmentResults", + column: "StudentId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentRules_ComprehensiveAssessmentDimensio~", + table: "ComprehensiveAssessmentRules", + column: "ComprehensiveAssessmentDimensionId"); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentRules_ComprehensiveAssessmentSchemeId~", + table: "ComprehensiveAssessmentRules", + columns: new[] { "ComprehensiveAssessmentSchemeId", "ComprehensiveAssessmentDimensionId", "Category", "Level" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentSchemes_CollegeId_Status_CreatedAt", + table: "ComprehensiveAssessmentSchemes", + columns: new[] { "CollegeId", "Status", "CreatedAt" }); + + migrationBuilder.CreateIndex( + name: "IX_ComprehensiveAssessmentSchemes_CreatedByUserId", + table: "ComprehensiveAssessmentSchemes", + column: "CreatedByUserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ComprehensiveAssessmentAppeals"); + + migrationBuilder.DropTable( + name: "ComprehensiveAssessmentDeclarations"); + + migrationBuilder.DropTable( + name: "ComprehensiveAssessmentPublications"); + + migrationBuilder.DropTable( + name: "ComprehensiveAssessmentResultDetails"); + + migrationBuilder.DropTable( + name: "ComprehensiveAssessmentRules"); + + migrationBuilder.DropTable( + name: "ComprehensiveAssessmentResults"); + + migrationBuilder.DropTable( + name: "ComprehensiveAssessmentDimensions"); + + migrationBuilder.DropTable( + name: "ComprehensiveAssessmentBatches"); + + migrationBuilder.DropTable( + name: "ComprehensiveAssessmentSchemes"); + } + } +} diff --git a/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/AppDbContextModelSnapshot.cs b/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/AppDbContextModelSnapshot.cs index 52511c8..02f11fd 100644 --- a/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/AppDbContextModelSnapshot.cs +++ b/src/Jiaowu.Api/Infrastructure/Persistence/Migrations/MySql/AppDbContextModelSnapshot.cs @@ -1278,6 +1278,522 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql b.ToTable("Colleges"); }); + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentAppeal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentBatchId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentResultDetailId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Reason") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("ReviewComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("ReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("ReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentResultDetailId"); + + b.HasIndex("StudentId"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "StudentId", "Status"); + + b.ToTable("ComprehensiveAssessmentAppeals"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("AcademicTermId") + .HasColumnType("char(36)"); + + b.Property("AcademicYear") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("varchar(20)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CalculationError") + .HasMaxLength(2000) + .HasColumnType("varchar(2000)"); + + b.Property("CalculationStatus") + .HasColumnType("int"); + + b.Property("CollegeId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentSchemeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("PublicationCount") + .HasColumnType("int"); + + b.Property("PublicityEndsAt") + .HasColumnType("datetime(6)"); + + b.Property("PublicityStartsAt") + .HasColumnType("datetime(6)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("AcademicTermId"); + + b.HasIndex("CollegeId"); + + b.HasIndex("ComprehensiveAssessmentSchemeId"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("AcademicYear", "CollegeId", "Status", "CreatedAt"); + + b.ToTable("ComprehensiveAssessmentBatches"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDeclaration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ApprovedScore") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("ClaimedScore") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("CollegeComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("CollegeReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("CollegeReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentBatchId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentDimensionId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentRuleId") + .HasColumnType("char(36)"); + + b.Property("CounselorComment") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("CounselorReviewedAt") + .HasColumnType("datetime(6)"); + + b.Property("CounselorReviewedByUserId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("EvidenceDescription") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("EvidenceUrl") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("OccurredOn") + .HasColumnType("date"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("SubmittedAt") + .HasColumnType("datetime(6)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("varchar(200)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentDimensionId"); + + b.HasIndex("ComprehensiveAssessmentRuleId"); + + b.HasIndex("StudentId", "OccurredOn"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "StudentId", "Status"); + + b.ToTable("ComprehensiveAssessmentDeclarations"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("varchar(50)"); + + b.Property("ComprehensiveAssessmentSchemeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("IsRequired") + .HasColumnType("tinyint(1)"); + + b.Property("MaxScore") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("SettingsJson") + .HasColumnType("text"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("SourceType") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Weight") + .HasPrecision(5, 2) + .HasColumnType("decimal(5,2)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentSchemeId", "Code") + .IsUnique(); + + b.ToTable("ComprehensiveAssessmentDimensions"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentPublication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentBatchId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Note") + .HasMaxLength(500) + .HasColumnType("varchar(500)"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("PublishedByUserId") + .HasColumnType("char(36)"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PublishedByUserId"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "Version") + .IsUnique(); + + b.ToTable("ComprehensiveAssessmentPublications"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResult", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CalculatedAt") + .HasColumnType("datetime(6)"); + + b.Property("ClassRank") + .HasColumnType("int"); + + b.Property("CollegeRank") + .HasColumnType("int"); + + b.Property("ComprehensiveAssessmentBatchId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("MajorRank") + .HasColumnType("int"); + + b.Property("MissingRequiredDimensionCount") + .HasColumnType("int"); + + b.Property("StudentId") + .HasColumnType("char(36)"); + + b.Property("TotalScore") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("StudentId"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "ClassRank"); + + b.HasIndex("ComprehensiveAssessmentBatchId", "StudentId") + .IsUnique() + .HasDatabaseName("IX_ComprehensiveAssessmentResults_ComprehensiveAssessmentBatch~1"); + + b.ToTable("ComprehensiveAssessmentResults"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResultDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentDimensionId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentResultId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Explanation") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("RawScore") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.Property("SourceSnapshotJson") + .HasColumnType("longtext"); + + b.Property("SourceStatus") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("WeightedScore") + .HasPrecision(8, 2) + .HasColumnType("decimal(8,2)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentDimensionId"); + + b.HasIndex("ComprehensiveAssessmentResultId", "ComprehensiveAssessmentDimensionId") + .IsUnique() + .HasDatabaseName("IX_ComprehensiveAssessmentResultDetails_ComprehensiveAssessmen~1"); + + b.ToTable("ComprehensiveAssessmentResultDetails"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("Category") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("CategoryCap") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("ComprehensiveAssessmentDimensionId") + .HasColumnType("char(36)"); + + b.Property("ComprehensiveAssessmentSchemeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Level") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Score") + .HasPrecision(7, 2) + .HasColumnType("decimal(7,2)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("ComprehensiveAssessmentDimensionId"); + + b.HasIndex("ComprehensiveAssessmentSchemeId", "ComprehensiveAssessmentDimensionId", "Category", "Level") + .IsUnique(); + + b.ToTable("ComprehensiveAssessmentRules"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CollegeId") + .HasColumnType("char(36)"); + + b.Property("CreatedAt") + .HasColumnType("datetime(6)"); + + b.Property("CreatedByUserId") + .HasColumnType("char(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("varchar(150)"); + + b.Property("Notes") + .HasMaxLength(1000) + .HasColumnType("varchar(1000)"); + + b.Property("PublicityDays") + .HasColumnType("int"); + + b.Property("PublishedAt") + .HasColumnType("datetime(6)"); + + b.Property("RankingScope") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime(6)"); + + b.Property("Version") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedByUserId"); + + b.HasIndex("CollegeId", "Status", "CreatedAt"); + + b.ToTable("ComprehensiveAssessmentSchemes"); + }); + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Course", b => { b.Property("Id") @@ -7839,6 +8355,205 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql b.Navigation("Campus"); }); + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentAppeal", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", "Batch") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResultDetail", "ResultDetail") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentResultDetailId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Batch"); + + b.Navigation("ResultDetail"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.AcademicTerm", "AcademicTerm") + .WithMany() + .HasForeignKey("AcademicTermId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.College", "College") + .WithMany() + .HasForeignKey("CollegeId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", "Scheme") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentSchemeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("AcademicTerm"); + + b.Navigation("College"); + + b.Navigation("CreatedByUser"); + + b.Navigation("Scheme"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDeclaration", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", "Batch") + .WithMany("Declarations") + .HasForeignKey("ComprehensiveAssessmentBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", "Dimension") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentDimensionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentRule", "Rule") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentRuleId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Batch"); + + b.Navigation("Dimension"); + + b.Navigation("Rule"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", "Scheme") + .WithMany("Dimensions") + .HasForeignKey("ComprehensiveAssessmentSchemeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Scheme"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentPublication", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", "Batch") + .WithMany("Publications") + .HasForeignKey("ComprehensiveAssessmentBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "PublishedByUser") + .WithMany() + .HasForeignKey("PublishedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Batch"); + + b.Navigation("PublishedByUser"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResult", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", "Batch") + .WithMany("Results") + .HasForeignKey("ComprehensiveAssessmentBatchId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.Student", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Batch"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResultDetail", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", "Dimension") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentDimensionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResult", "Result") + .WithMany("Details") + .HasForeignKey("ComprehensiveAssessmentResultId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_ComprehensiveAssessmentResultDetails_ComprehensiveAssessmen~1"); + + b.Navigation("Dimension"); + + b.Navigation("Result"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentRule", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentDimension", "Dimension") + .WithMany() + .HasForeignKey("ComprehensiveAssessmentDimensionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", "Scheme") + .WithMany("Rules") + .HasForeignKey("ComprehensiveAssessmentSchemeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Dimension"); + + b.Navigation("Scheme"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", b => + { + b.HasOne("Jiaowu.Api.Domain.Academic.College", "College") + .WithMany() + .HasForeignKey("CollegeId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Jiaowu.Api.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedByUserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("College"); + + b.Navigation("CreatedByUser"); + }); + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Course", b => { b.HasOne("Jiaowu.Api.Domain.Academic.College", "College") @@ -9773,6 +10488,27 @@ namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql b.Navigation("Transactions"); }); + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentBatch", b => + { + b.Navigation("Declarations"); + + b.Navigation("Publications"); + + b.Navigation("Results"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentResult", b => + { + b.Navigation("Details"); + }); + + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.ComprehensiveAssessmentScheme", b => + { + b.Navigation("Dimensions"); + + b.Navigation("Rules"); + }); + modelBuilder.Entity("Jiaowu.Api.Domain.Academic.Course", b => { b.Navigation("Prerequisites"); diff --git a/src/Jiaowu.Api/Infrastructure/Plugins/BuiltInPluginCatalog.cs b/src/Jiaowu.Api/Infrastructure/Plugins/BuiltInPluginCatalog.cs index 6752e27..20cbf50 100644 --- a/src/Jiaowu.Api/Infrastructure/Plugins/BuiltInPluginCatalog.cs +++ b/src/Jiaowu.Api/Infrastructure/Plugins/BuiltInPluginCatalog.cs @@ -75,6 +75,15 @@ public sealed class BuiltInPluginCatalog ["/physical-fitness"], ["/api/physical-fitness"], ["physical-fitness.read", "physical-fitness.manage"]), + new( + "mingxu.comprehensive-assessment", + "学生综合测评", + "提供测评方案、材料申报审核、自动汇总、排名、公示和申诉。", + "1.0.0", + "学生工作", + ["/comprehensive-assessments"], + ["/api/comprehensive-assessments"], + ["comprehensive-assessment.read", "comprehensive-assessment.manage"]), new( "mingxu.student-services", "学籍与学生服务", diff --git a/src/Jiaowu.Api/Program.cs b/src/Jiaowu.Api/Program.cs index d45b766..99d3e29 100644 --- a/src/Jiaowu.Api/Program.cs +++ b/src/Jiaowu.Api/Program.cs @@ -269,6 +269,7 @@ if (backgroundJobOptions.PollIntervalMilliseconds is < 100 or > 30000 || backgroundJobOptions.DegreeAwardCalculationConcurrency is < 1 or > 16 || backgroundJobOptions.DormitoryAutomaticAllocationConcurrency is < 1 or > 16 || backgroundJobOptions.DormitoryHygieneCalculationConcurrency is < 1 or > 16 || + backgroundJobOptions.ComprehensiveAssessmentCalculationConcurrency is < 1 or > 16 || backgroundJobOptions.ProcessingAttemptLimit is < 1 or > 100 || backgroundJobOptions.MaintenanceIntervalSeconds is < 10 or > 3600 || backgroundJobOptions.CompletedRetentionDays is < 1 or > 3650 || @@ -497,6 +498,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddSingleton(TimeProvider.System); diff --git a/src/Jiaowu.Api/appsettings.json b/src/Jiaowu.Api/appsettings.json index 393377f..e5343cc 100644 --- a/src/Jiaowu.Api/appsettings.json +++ b/src/Jiaowu.Api/appsettings.json @@ -87,6 +87,7 @@ "DegreeAwardCalculationConcurrency": 1, "DormitoryAutomaticAllocationConcurrency": 1, "DormitoryHygieneCalculationConcurrency": 1, + "ComprehensiveAssessmentCalculationConcurrency": 1, "Exchange": "jiaowu.background-jobs", "QueuePrefix": "jiaowu.background-jobs", "UseQuorumQueues": true, diff --git a/tests/Jiaowu.Api.Tests/ComprehensiveAssessmentsControllerTests.cs b/tests/Jiaowu.Api.Tests/ComprehensiveAssessmentsControllerTests.cs new file mode 100644 index 0000000..c552b8f --- /dev/null +++ b/tests/Jiaowu.Api.Tests/ComprehensiveAssessmentsControllerTests.cs @@ -0,0 +1,159 @@ +using Jiaowu.Api.Controllers; +using Jiaowu.Api.Domain.Academic; +using Jiaowu.Api.Domain.Identity; +using Jiaowu.Api.Infrastructure.Assessments; +using Jiaowu.Api.Infrastructure.Auth; +using Jiaowu.Api.Infrastructure.Persistence; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; + +namespace Jiaowu.Api.Tests; + +public sealed class ComprehensiveAssessmentsControllerTests +{ + [Fact] + public async Task Calculation_UsesPublishedSnapshotsAndApprovedDeclarations() + { + await using var fixture = await Fixture.CreateAsync(includeSecondStudent: true); + fixture.Db.StudentAcademicTermStatistics.AddRange( + new StudentAcademicTermStatistic + { + StudentId = fixture.Student.Id, AcademicTermId = fixture.Term.Id, + CourseCount = 6, WeightedAverageScore = 80, AverageScore = 79, + CalculatedAt = DateTime.UtcNow + }, + new StudentAcademicTermStatistic + { + StudentId = fixture.OtherStudent!.Id, AcademicTermId = fixture.Term.Id, + CourseCount = 6, WeightedAverageScore = 90, AverageScore = 89, + CalculatedAt = DateTime.UtcNow + }); + fixture.Db.ComprehensiveAssessmentDeclarations.Add(new ComprehensiveAssessmentDeclaration + { + ComprehensiveAssessmentBatchId = fixture.Batch.Id, + StudentId = fixture.Student.Id, + ComprehensiveAssessmentDimensionId = fixture.DeclarationDimension.Id, + Title = "省级竞赛", Category = "学科竞赛", Level = "省级", + OccurredOn = new DateOnly(2026, 10, 1), ClaimedScore = 20, + ApprovedScore = 20, Status = ComprehensiveAssessmentDeclarationStatus.Approved + }); + await fixture.Db.SaveChangesAsync(); + + await new ComprehensiveAssessmentCalculationProcessor(fixture.Db) + .ProcessAsync(fixture.Batch.Id, CancellationToken.None); + + fixture.Db.ChangeTracker.Clear(); + var result = await fixture.Db.ComprehensiveAssessmentResults.Include(x => x.Details) + .SingleAsync(x => x.StudentId == fixture.Student.Id); + var other = await fixture.Db.ComprehensiveAssessmentResults + .SingleAsync(x => x.StudentId == fixture.OtherStudent.Id); + Assert.Equal(56m, result.TotalScore); + Assert.Equal(54m, other.TotalScore); + Assert.Equal(1, result.ClassRank); + Assert.Equal(2, other.ClassRank); + Assert.Equal(2, result.Details.Count); + Assert.Equal(ComprehensiveAssessmentCalculationStatus.Succeeded, + (await fixture.Db.ComprehensiveAssessmentBatches.FindAsync(fixture.Batch.Id))!.CalculationStatus); + } + + [Fact] + public async Task CounselorPendingDeclarations_IsLimitedToAssignedClasses() + { + await using var fixture = await Fixture.CreateAsync(includeSecondStudent: true, secondClass: true); + fixture.Db.ComprehensiveAssessmentDeclarations.AddRange( + Declaration(fixture.Batch.Id, fixture.Student.Id, fixture.DeclarationDimension.Id, "本班材料"), + Declaration(fixture.Batch.Id, fixture.OtherStudent!.Id, fixture.DeclarationDimension.Id, "其他班材料")); + await fixture.Db.SaveChangesAsync(); + var controller = new ComprehensiveAssessmentsController(fixture.Db, fixture.CounselorScope); + + var response = Assert.IsType(await controller.PendingDeclarations(CancellationToken.None)); + var items = Assert.IsAssignableFrom>(response.Value).ToList(); + Assert.Single(items); + Assert.Equal("本班材料", items[0].Title); + } + + [Fact] + public async Task StudentCannotAppealOutsidePublicityPeriod() + { + await using var fixture = await Fixture.CreateAsync(); + var controller = new ComprehensiveAssessmentsController(fixture.Db, fixture.StudentScope); + + var response = await controller.CreateAppeal( + new ComprehensiveAssessmentAppealRequest(fixture.Batch.Id, null, "分数有误"), + CancellationToken.None); + + Assert.IsType(response); + } + + private static ComprehensiveAssessmentDeclaration Declaration(Guid batchId, Guid studentId, Guid dimensionId, string title) => new() + { + ComprehensiveAssessmentBatchId = batchId, StudentId = studentId, + ComprehensiveAssessmentDimensionId = dimensionId, Title = title, + Category = "志愿服务", Level = "校级", OccurredOn = new DateOnly(2026, 10, 1), + ClaimedScore = 5, Status = ComprehensiveAssessmentDeclarationStatus.Submitted, + SubmittedAt = DateTime.UtcNow + }; + + private sealed class Fixture : IAsyncDisposable + { + private readonly SqliteConnection connection; + public AppDbContext Db { get; } + public Student Student { get; } + public Student? OtherStudent { get; } + public AcademicTerm Term { get; } + public ComprehensiveAssessmentBatch Batch { get; } + public ComprehensiveAssessmentDimension DeclarationDimension { get; } + public ICurrentUserDataScope CounselorScope { get; } + public ICurrentUserDataScope StudentScope { get; } + + private Fixture(SqliteConnection connection, AppDbContext db, Student student, + Student? otherStudent, AcademicTerm term, ComprehensiveAssessmentBatch batch, + ComprehensiveAssessmentDimension declarationDimension, Guid counselorId) + { + this.connection = connection; Db = db; Student = student; OtherStudent = otherStudent; + Term = term; Batch = batch; DeclarationDimension = declarationDimension; + CounselorScope = new TestScope(counselorId, null, DataScope.Class, SystemRoles.Counselor); + StudentScope = new TestScope(student.UserId!.Value, null, DataScope.Self, SystemRoles.Student); + } + + public static async Task CreateAsync(bool includeSecondStudent = false, bool secondClass = false) + { + var connection = new SqliteConnection("Data Source=:memory:"); + await connection.OpenAsync(); + var db = new AppDbContext(new DbContextOptionsBuilder().UseSqlite(connection).Options); + await db.Database.EnsureCreatedAsync(); + var manager = new ApplicationUser { Id = Guid.NewGuid(), UserName = "manager", NormalizedUserName = "MANAGER", DisplayName = "管理员", SecurityStamp = Guid.NewGuid().ToString() }; + var studentUser = new ApplicationUser { Id = Guid.NewGuid(), UserName = "student", NormalizedUserName = "STUDENT", DisplayName = "学生甲", SecurityStamp = Guid.NewGuid().ToString() }; + var counselorId = Guid.NewGuid(); + var counselor = new ApplicationUser { Id = counselorId, UserName = "counselor", NormalizedUserName = "COUNSELOR", DisplayName = "辅导员", SecurityStamp = Guid.NewGuid().ToString() }; + var college = new College { Code = "CS", Name = "计算机学院" }; + var major = new Major { Code = "SE", Name = "软件工程", CollegeId = college.Id, DegreeType = "工学" }; + var assignedClass = new AdministrativeClass { Code = "SE2601", Name = "软件 2601", MajorId = major.Id, Grade = 2026, CounselorUserId = counselorId }; + var otherCounselor = secondClass ? new ApplicationUser { Id = Guid.NewGuid(), UserName = "counselor2", NormalizedUserName = "COUNSELOR2", DisplayName = "其他辅导员", SecurityStamp = Guid.NewGuid().ToString() } : null; + var otherClass = secondClass + ? new AdministrativeClass { Code = "SE2602", Name = "软件 2602", MajorId = major.Id, Grade = 2026, CounselorUserId = otherCounselor!.Id } + : assignedClass; + var student = new Student { StudentNumber = "202600001", Name = "学生甲", Gender = Gender.Male, AdministrativeClassId = assignedClass.Id, EnrollmentYear = 2026, EnrollmentDate = new DateOnly(2026, 9, 1), UserId = studentUser.Id }; + Student? otherStudent = includeSecondStudent ? new Student { StudentNumber = "202600002", Name = "学生乙", Gender = Gender.Female, AdministrativeClassId = otherClass.Id, EnrollmentYear = 2026, EnrollmentDate = new DateOnly(2026, 9, 1) } : null; + var term = new AcademicTerm { Code = "2026-A", Name = "2026-2027 学年第一学期", AcademicYear = "2026-2027", Season = TermSeason.Autumn, StartDate = new DateOnly(2026, 9, 1), EndDate = new DateOnly(2027, 1, 20) }; + var scheme = new ComprehensiveAssessmentScheme { Name = "测试方案", Status = ComprehensiveAssessmentSchemeStatus.Published, CreatedByUserId = manager.Id, PublishedAt = DateTime.UtcNow }; + var academic = new ComprehensiveAssessmentDimension { Scheme = scheme, Code = "academic", Name = "学业表现", SourceType = ComprehensiveAssessmentSourceType.Academic, Weight = 60, MaxScore = 100, SortOrder = 1, IsRequired = true }; + var declaration = new ComprehensiveAssessmentDimension { Scheme = scheme, Code = "honors", Name = "荣誉实践", SourceType = ComprehensiveAssessmentSourceType.Declaration, Weight = 40, MaxScore = 100, SortOrder = 2 }; + var batch = new ComprehensiveAssessmentBatch { Scheme = scheme, Name = "2026 综合测评", AcademicYear = "2026-2027", AcademicTermId = term.Id, CollegeId = college.Id, Status = ComprehensiveAssessmentBatchStatus.Reviewing, CreatedByUserId = manager.Id }; + db.AddRange(manager, studentUser, counselor, college, major, assignedClass); + if (secondClass) db.AddRange(otherCounselor!, otherClass); + db.AddRange(student, term, scheme, academic, declaration, batch); + if (otherStudent is not null) db.Add(otherStudent); + await db.SaveChangesAsync(); + return new Fixture(connection, db, student, otherStudent, term, batch, declaration, counselorId); + } + + public async ValueTask DisposeAsync() { await Db.DisposeAsync(); await connection.DisposeAsync(); } + } + + private sealed class TestScope(Guid userId, Guid? collegeId, DataScope scope, string role) : ICurrentUserDataScope + { + public CurrentUserScope Current { get; } = new(userId, "测试用户", collegeId, scope, new HashSet([role])); + } +} diff --git a/web/src/layouts/AdminLayout.vue b/web/src/layouts/AdminLayout.vue index 953a544..3dfc7bc 100644 --- a/web/src/layouts/AdminLayout.vue +++ b/web/src/layouts/AdminLayout.vue @@ -81,6 +81,7 @@ const stableNavigationIds: Record = { '/exams': 'exams', '/makeup-exams': 'makeup-exams', '/physical-fitness': 'physical-fitness', + '/comprehensive-assessments': 'comprehensive-assessments', '/my-profile': 'my-profile', '/student-status-changes': 'student-status-changes', '/official-documents': 'official-documents', @@ -364,6 +365,16 @@ const availableNavigationGroups = computed(() => [ ), ], }, + { + key: 'student-development', + label: '学生发展', + items: [ + ...whenVisible( + hasAnyRole(['SuperAdmin', 'AcademicAdmin', 'StudentAffairsAdmin', 'CollegeAdmin', 'Counselor', 'Leader', 'Student']), + { path: '/comprehensive-assessments', label: isStudent.value ? '我的综合测评' : '综合测评' }, + ), + ], + }, { key: 'student-status', label: '学籍与服务', @@ -473,6 +484,7 @@ const workspaceLabel = computed(() => { if (roles.value.includes('AcademicAdmin')) return '校级教务管理' if (roles.value.includes('CollegeAdmin')) return '学院教务管理' if (roles.value.includes('DormitoryAdmin')) return '宿舍管理工作台' + if (roles.value.includes('StudentAffairsAdmin')) return '学生工作管理台' if (roles.value.includes('Counselor')) return '辅导员班级工作' if (roles.value.includes('Teacher')) return '教师教学工作' if (roles.value.includes('Student')) return '学生学业服务' diff --git a/web/src/router/index.ts b/web/src/router/index.ts index e9bcaf4..aae4f88 100644 --- a/web/src/router/index.ts +++ b/web/src/router/index.ts @@ -391,6 +391,12 @@ const router = createRouter({ component: () => import('../views/PhysicalFitnessView.vue'), meta: { roles: ['SuperAdmin', 'AcademicAdmin', 'PhysicalEducationAdmin', 'CollegeAdmin', 'Counselor', 'Student'], pluginId: 'mingxu.physical-fitness' }, }, + { + path: 'comprehensive-assessments', + name: 'comprehensive-assessments', + component: () => import('../views/ComprehensiveAssessmentsView.vue'), + meta: { roles: ['SuperAdmin', 'AcademicAdmin', 'StudentAffairsAdmin', 'CollegeAdmin', 'Counselor', 'Leader', 'Student'], pluginId: 'mingxu.comprehensive-assessment' }, + }, { path: 'exams', name: 'exams', diff --git a/web/src/views/AcademicCalendarView.vue b/web/src/views/AcademicCalendarView.vue index 0eedc29..1b676a4 100644 --- a/web/src/views/AcademicCalendarView.vue +++ b/web/src/views/AcademicCalendarView.vue @@ -56,6 +56,7 @@ const roles = [ ["MaintenanceStaff", "维修人员"], ["PhysicalEducationAdmin", "体测管理员"], ["DormitoryAdmin", "宿管管理员"], + ["StudentAffairsAdmin", "学工管理员"], ]; const kinds = [ [1, "选课"], diff --git a/web/src/views/ComprehensiveAssessmentsView.vue b/web/src/views/ComprehensiveAssessmentsView.vue new file mode 100644 index 0000000..da3f111 --- /dev/null +++ b/web/src/views/ComprehensiveAssessmentsView.vue @@ -0,0 +1,183 @@ + + + + +