Support enlistment and class assignment on resumption

This commit is contained in:
biss committed 2026-11-08 15:36:35 +08:00
1 parent fda90d60a9
commit 15536cc62f
22 files changed
+24481 -40

No files matched your search

@@ -281,9 +281,13 @@ public sealed class ApprovalsController(
if (manager || current.IsInRole(SystemRoles.Counselor))
{
if (current.Scope == DataScope.College)
query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.Major!.CollegeId == current.RestrictedCollegeId);
query = query.Where(x => x.Student!.UserId == userId || (x.OriginalClass != null
? x.OriginalClass.Major!.CollegeId == current.RestrictedCollegeId
: x.Student.AdministrativeClass!.Major!.CollegeId == current.RestrictedCollegeId));
else if (current.Scope == DataScope.Class)
query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.CounselorUserId == userId);
query = query.Where(x => x.Student!.UserId == userId ||
(x.OriginalClass != null ? x.OriginalClass.CounselorUserId : x.Student.AdministrativeClass!.CounselorUserId) == userId ||
x.State == StudentStatusChangeState.Approved && x.TargetClass != null && x.TargetClass.CounselorUserId == userId);
else if (current.Scope != DataScope.All)
query = query.Where(x => x.Student!.UserId == userId);
}
@@ -1309,7 +1313,7 @@ public sealed class ApprovalsController(
if (typeof(T) == typeof(DeferredExam)) return (IQueryable<T>)((IQueryable<DeferredExam>)(object)q).Where(x => x.TeachingTask!.Course!.CollegeId == cid);
if (typeof(T) == typeof(GradeModification)) return (IQueryable<T>)((IQueryable<GradeModification>)(object)q).Where(x => x.GradeRecord!.GradeSheet!.TeachingTask!.Course!.CollegeId == cid);
if (typeof(T) == typeof(CourseSubstitution)) return (IQueryable<T>)((IQueryable<CourseSubstitution>)(object)q).Where(x => x.Student!.AdministrativeClass!.Major!.CollegeId == cid);
if (typeof(T) == typeof(StudentStatusChange)) return (IQueryable<T>)((IQueryable<StudentStatusChange>)(object)q).Where(x => x.Student!.AdministrativeClass!.Major!.CollegeId == cid);
if (typeof(T) == typeof(StudentStatusChange)) return (IQueryable<T>)((IQueryable<StudentStatusChange>)(object)q).Where(x => x.OriginalClass != null ? x.OriginalClass.Major!.CollegeId == cid : x.Student!.AdministrativeClass!.Major!.CollegeId == cid);
if (typeof(T) == typeof(CourseAdjustment)) return (IQueryable<T>)((IQueryable<CourseAdjustment>)(object)q).Where(x => x.TeachingTask!.Course!.CollegeId == cid);
if (typeof(T) == typeof(GradeSheet)) return (IQueryable<T>)((IQueryable<GradeSheet>)(object)q).Where(x => x.TeachingTask!.Course!.CollegeId == cid);
if (typeof(T) == typeof(AttendanceRecord)) return (IQueryable<T>)((IQueryable<AttendanceRecord>)(object)q).Where(x => x.Student!.AdministrativeClass!.Major!.CollegeId == cid);
@@ -1359,7 +1363,7 @@ public sealed class ApprovalsController(
private async Task NotifyCollege(GradeModification gm, CancellationToken ct) { await NotificationService.SendToRoleAsync(db, SystemRoles.CollegeAdmin, "成绩修改待审核", $"{gm.GradeRecord!.Student!.Name} — 《{gm.GradeRecord.GradeSheet!.TeachingTask!.Course!.Name}》{gm.CurrentScore}→{gm.RequestedScore}", cancellationToken: ct, category: NotificationCategory.Grade); }
private async Task NotifyRole(string role, string title, string content, CancellationToken ct) { await NotificationService.SendToRoleAsync(db, role, title, content, cancellationToken: ct, category: NotificationCategory.Approval); }
private static string SSCLabel(StudentStatusChangeType t) => t switch { StudentStatusChangeType.Suspension => "休学", StudentStatusChangeType.Resumption => "复学", StudentStatusChangeType.Withdrawal => "退学", _ => "异动" };
private static string SSCLabel(StudentStatusChangeType t) => t switch { StudentStatusChangeType.Suspension => "休学", StudentStatusChangeType.Resumption => "复学", StudentStatusChangeType.Withdrawal => "退学", StudentStatusChangeType.Enlistment => "入伍保留学籍", _ => "异动" };
private static string CALabel(CourseAdjustmentType t) => t switch { CourseAdjustmentType.Reschedule => "调课", CourseAdjustmentType.Cancel => "停课", CourseAdjustmentType.Makeup => "补课", CourseAdjustmentType.Substitute => "代课", _ => "调停课" };
private ActionResult ConflictProblem(string d) => Conflict(new ProblemDetails { Title = "无法完成", Detail = d, Status = 409 });
}
@@ -87,10 +87,11 @@ public sealed class AttendanceController(
StudentCount = db.Students.Count(student =>
(!counselorOnly ||
student.AdministrativeClass!.CounselorUserId == scope.UserId) &&
((student.Status == StudentStatus.Active &&
x.Classes.Any(assignment =>
student.Status == StudentStatus.Active &&
!db.StudentStatusChangeCourseEffects.Any(effect => effect.StudentId == student.Id && effect.TeachingTaskId == x.Id) &&
(x.Classes.Any(assignment =>
assignment.AdministrativeClassId ==
student.AdministrativeClassId)) ||
student.AdministrativeClassId) ||
db.CourseEnrollments.Any(enrollment =>
enrollment.StudentId == student.Id &&
enrollment.Status == CourseEnrollmentStatus.Enrolled &&
@@ -1816,14 +1816,15 @@ public sealed class CourseSelectionsController(
CourseName = x.Course.Name,
x.Capacity,
StudentCount = db.Students.Count(student =>
(student.Status == StudentStatus.Active &&
x.Classes.Any(assignment =>
student.Status == StudentStatus.Active &&
!db.StudentStatusChangeCourseEffects.Any(effect => effect.StudentId == student.Id && effect.TeachingTaskId == x.Id) &&
(x.Classes.Any(assignment =>
assignment.AdministrativeClassId ==
student.AdministrativeClassId)) ||
student.AdministrativeClassId) ||
db.CourseEnrollments.Any(enrollment =>
enrollment.StudentId == student.Id &&
enrollment.Status == CourseEnrollmentStatus.Enrolled &&
enrollment.CourseSelectionOffering!.TeachingTaskId == x.Id))
enrollment.CourseSelectionOffering!.TeachingTaskId == x.Id)))
})
.ToListAsync(cancellationToken));
}
Loaded 3 of 22 files, more files were not shown because too many files have changed in this diff. Show more