Enable direct review and filter approval queues

This commit is contained in:
biss committed 2026-11-07 20:22:47 +08:00
1 parent 2d1a43fd39
commit 88ef93022d
6 files changed
+169 -26

No files matched your search

@@ -61,7 +61,8 @@ public sealed class ApprovalsController(
int page = 1,
int pageSize = 20,
CancellationToken ct = default,
bool oldestFirst = false)
bool oldestFirst = false,
string? type = null)
{
if (page < 1 || pageSize is < 1 or > 100 || (long)page * pageSize > 100000)
return ValidationProblem("page 必须大于 0,pageSize 必须在 1 到 100 之间,且分页窗口不能超过 100000 条。");
@@ -114,7 +115,7 @@ public sealed class ApprovalsController(
var canCollegeReview = scope.Current.IsInRole(SystemRoles.CollegeAdmin);
items.AddRange(await Scoped<StudentStatusChange>(x => (canCollegeReview && x.State == StudentStatusChangeState.CounselorApproved) || (canFinalReview && x.State == StudentStatusChangeState.CollegeApproved))
.OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", $"{x.Student!.Name} — {SSCLabel(x.Type)}", x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name))
.Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", $"{x.Student!.Name} — {SSCLabel(x.Type)}", x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name, x.State == StudentStatusChangeState.CounselorApproved ? "college" : "final"))
.ToListAsync(ct));
AddCount("StudentStatusChange", await Scoped<StudentStatusChange>(x => (canCollegeReview && x.State == StudentStatusChangeState.CounselorApproved) || (canFinalReview && x.State == StudentStatusChangeState.CollegeApproved)).CountAsync(ct));
@@ -189,7 +190,7 @@ public sealed class ApprovalsController(
items.AddRange(await dormApplications.OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请",
x.Student!.Name, x.Reason, x.SubmittedAt,
x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct));
x.Student.AdministrativeClass!.Major!.College!.Name, x.Status == DormitoryApplicationStatus.Submitted ? "counselor" : "dormitory")).ToListAsync(ct));
AddCount("DormitoryApplication", await dormApplications.CountAsync(ct));
}
@@ -197,7 +198,7 @@ public sealed class ApprovalsController(
items.AddRange(await declarations.OrderByApprovalTime(x => x.SubmittedAt ?? x.CreatedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料复核",
$"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt,
x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct));
x.Student.AdministrativeClass!.Major!.College!.Name, "college")).ToListAsync(ct));
AddCount("AssessmentDeclaration", await declarations.CountAsync(ct));
var assessmentAppeals = Scoped<ComprehensiveAssessmentAppeal>(x => x.Status == ComprehensiveAssessmentAppealStatus.Submitted);
@@ -213,17 +214,17 @@ public sealed class ApprovalsController(
var userId = current.UserId;
var changes = db.StudentStatusChanges.AsNoTracking().Where(x => x.State == StudentStatusChangeState.Submitted && x.Student!.AdministrativeClass!.CounselorUserId == userId);
items.AddRange(await changes.OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct));
.Select(x => new ApprovalItem(x.Id, "StudentStatusChange", "学籍异动", $"{x.Student!.Name} — {SSCLabel(x.Type)}", x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "counselor")).ToListAsync(ct));
AddCount("StudentStatusChange", await changes.CountAsync(ct));
var declarations = db.ComprehensiveAssessmentDeclarations.AsNoTracking().Where(x => x.Status == ComprehensiveAssessmentDeclarationStatus.Submitted && x.Student!.AdministrativeClass!.CounselorUserId == userId);
items.AddRange(await declarations.OrderByApprovalTime(x => x.SubmittedAt ?? x.CreatedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料初审", $"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct));
.Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料初审", $"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "counselor")).ToListAsync(ct));
AddCount("AssessmentDeclaration", await declarations.CountAsync(ct));
if (!isManager)
{
var dorm = db.DormitoryApplications.AsNoTracking().Where(x => x.Status == DormitoryApplicationStatus.Submitted && x.Student!.AdministrativeClass!.CounselorUserId == userId);
items.AddRange(await dorm.OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct));
.Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "counselor")).ToListAsync(ct));
AddCount("DormitoryApplication", await dorm.CountAsync(ct));
}
}
@@ -253,14 +254,14 @@ public sealed class ApprovalsController(
{
var dorm = Scoped<DormitoryApplication>(x => x.Status == DormitoryApplicationStatus.CounselorApproved);
items.AddRange(await dorm.OrderByApprovalTime(x => x.SubmittedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct));
.Select(x => new ApprovalItem(x.Id, "DormitoryApplication", "住宿申请", x.Student!.Name, x.Reason, x.SubmittedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "dormitory")).ToListAsync(ct));
AddCount("DormitoryApplication", await dorm.CountAsync(ct));
}
if (current.IsInRole(SystemRoles.StudentAffairsAdmin) && !isManager)
{
var declarations = Scoped<ComprehensiveAssessmentDeclaration>(x => x.Status == ComprehensiveAssessmentDeclarationStatus.CounselorApproved);
items.AddRange(await declarations.OrderByApprovalTime(x => x.SubmittedAt ?? x.CreatedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
.Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料复核", $"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt, x.Student.AdministrativeClass!.Major!.College!.Name)).ToListAsync(ct));
.Select(x => new ApprovalItem(x.Id, "AssessmentDeclaration", "综合测评材料复核", $"{x.Student!.Name} — {x.Title}", x.Category, x.SubmittedAt ?? x.CreatedAt, x.Student.AdministrativeClass!.Major!.College!.Name, "college")).ToListAsync(ct));
AddCount("AssessmentDeclaration", await declarations.CountAsync(ct));
var appeals = Scoped<ComprehensiveAssessmentAppeal>(x => x.Status == ComprehensiveAssessmentAppealStatus.Submitted);
items.AddRange(await appeals.OrderByApprovalTime(x => x.CreatedAt, oldestFirst).ThenBy(x => x.Id).Take(take)
@@ -296,7 +297,9 @@ public sealed class ApprovalsController(
AddCount("GraduationClearance", await clearances.CountAsync(ct));
}
var ordered = oldestFirst ? items.OrderBy(x => x.Time) : items.OrderByDescending(x => x.Time);
var filtered = string.IsNullOrWhiteSpace(type) ? items : items.Where(x => x.Type == type);
if (!string.IsNullOrWhiteSpace(type)) total = counts.GetValueOrDefault(type);
var ordered = oldestFirst ? filtered.OrderBy(x => x.Time) : filtered.OrderByDescending(x => x.Time);
var pageItems = ordered
.ThenBy(x => x.Type)
.ThenBy(x => x.Id)