筛选优化
This commit is contained in:
1 parent
ccdfe977ba
commit
0ce758191e
7 files changed
+119
-6
No files matched your search
@@ -37,7 +37,8 @@ public sealed class AttendanceController(
|
|||||||
string? keyword = null,
|
string? keyword = null,
|
||||||
int page = 1,
|
int page = 1,
|
||||||
int pageSize = 20,
|
int pageSize = 20,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default,
|
||||||
|
string? classKeyword = null)
|
||||||
{
|
{
|
||||||
page = Math.Max(1, page);
|
page = Math.Max(1, page);
|
||||||
pageSize = Math.Clamp(pageSize, 10, 50);
|
pageSize = Math.Clamp(pageSize, 10, 50);
|
||||||
@@ -54,6 +55,14 @@ public sealed class AttendanceController(
|
|||||||
x.Course!.Code.Contains(keyword) ||
|
x.Course!.Code.Contains(keyword) ||
|
||||||
x.Course.Name.Contains(keyword));
|
x.Course.Name.Contains(keyword));
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(classKeyword))
|
||||||
|
{
|
||||||
|
classKeyword = classKeyword.Trim();
|
||||||
|
tasks = tasks.Where(x => x.Classes.Any(item =>
|
||||||
|
item.AdministrativeClass!.Code.Contains(classKeyword) ||
|
||||||
|
item.AdministrativeClass.Name.Contains(classKeyword) ||
|
||||||
|
item.AdministrativeClass.Major!.Name.Contains(classKeyword)));
|
||||||
|
}
|
||||||
var total = await tasks.CountAsync(cancellationToken);
|
var total = await tasks.CountAsync(cancellationToken);
|
||||||
var result = await tasks
|
var result = await tasks
|
||||||
.OrderBy(x => x.Course!.Code)
|
.OrderBy(x => x.Course!.Code)
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ public sealed class GradesController(
|
|||||||
string? keyword = null,
|
string? keyword = null,
|
||||||
int page = 1,
|
int page = 1,
|
||||||
int pageSize = 20,
|
int pageSize = 20,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default,
|
||||||
|
Guid? collegeId = null,
|
||||||
|
string? teacherKeyword = null,
|
||||||
|
string? classKeyword = null)
|
||||||
{
|
{
|
||||||
page = Math.Max(1, page);
|
page = Math.Max(1, page);
|
||||||
pageSize = Math.Clamp(pageSize, 10, 50);
|
pageSize = Math.Clamp(pageSize, 10, 50);
|
||||||
@@ -61,6 +64,8 @@ public sealed class GradesController(
|
|||||||
x.Status == TeachingTaskStatus.Closed);
|
x.Status == TeachingTaskStatus.Closed);
|
||||||
if (academicTermId.HasValue)
|
if (academicTermId.HasValue)
|
||||||
source = source.Where(x => x.AcademicTermId == academicTermId);
|
source = source.Where(x => x.AcademicTermId == academicTermId);
|
||||||
|
if (collegeId.HasValue)
|
||||||
|
source = source.Where(x => x.Course!.CollegeId == collegeId.Value);
|
||||||
if (status.HasValue)
|
if (status.HasValue)
|
||||||
source = source.Where(x => db.GradeSheets.Any(sheet =>
|
source = source.Where(x => db.GradeSheets.Any(sheet =>
|
||||||
sheet.TeachingTaskId == x.Id && sheet.Status == status.Value));
|
sheet.TeachingTaskId == x.Id && sheet.Status == status.Value));
|
||||||
@@ -73,6 +78,21 @@ public sealed class GradesController(
|
|||||||
x.Course!.Code.Contains(keyword) ||
|
x.Course!.Code.Contains(keyword) ||
|
||||||
x.Course.Name.Contains(keyword));
|
x.Course.Name.Contains(keyword));
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(teacherKeyword))
|
||||||
|
{
|
||||||
|
teacherKeyword = teacherKeyword.Trim();
|
||||||
|
source = source.Where(x => x.Teachers.Any(item =>
|
||||||
|
item.Teacher!.Name.Contains(teacherKeyword) ||
|
||||||
|
item.Teacher.TeacherNumber.Contains(teacherKeyword)));
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(classKeyword))
|
||||||
|
{
|
||||||
|
classKeyword = classKeyword.Trim();
|
||||||
|
source = source.Where(x => x.Classes.Any(item =>
|
||||||
|
item.AdministrativeClass!.Code.Contains(classKeyword) ||
|
||||||
|
item.AdministrativeClass.Name.Contains(classKeyword) ||
|
||||||
|
item.AdministrativeClass.Major!.Name.Contains(classKeyword)));
|
||||||
|
}
|
||||||
|
|
||||||
var total = await source.CountAsync(cancellationToken);
|
var total = await source.CountAsync(cancellationToken);
|
||||||
var items = await source
|
var items = await source
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ public sealed class TeachingTasksController(
|
|||||||
Guid? academicTermId = null,
|
Guid? academicTermId = null,
|
||||||
Guid? collegeId = null,
|
Guid? collegeId = null,
|
||||||
TeachingTaskStatus? status = null,
|
TeachingTaskStatus? status = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default,
|
||||||
|
string? teacherKeyword = null,
|
||||||
|
string? classKeyword = null)
|
||||||
{
|
{
|
||||||
page = Math.Max(1, page);
|
page = Math.Max(1, page);
|
||||||
pageSize = Math.Clamp(pageSize, 10, 100);
|
pageSize = Math.Clamp(pageSize, 10, 100);
|
||||||
@@ -56,6 +58,21 @@ public sealed class TeachingTasksController(
|
|||||||
x.Course!.Code.Contains(keyword) ||
|
x.Course!.Code.Contains(keyword) ||
|
||||||
x.Course.Name.Contains(keyword));
|
x.Course.Name.Contains(keyword));
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(teacherKeyword))
|
||||||
|
{
|
||||||
|
teacherKeyword = teacherKeyword.Trim();
|
||||||
|
source = source.Where(x => x.Teachers.Any(item =>
|
||||||
|
item.Teacher!.Name.Contains(teacherKeyword) ||
|
||||||
|
item.Teacher.TeacherNumber.Contains(teacherKeyword)));
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(classKeyword))
|
||||||
|
{
|
||||||
|
classKeyword = classKeyword.Trim();
|
||||||
|
source = source.Where(x => x.Classes.Any(item =>
|
||||||
|
item.AdministrativeClass!.Code.Contains(classKeyword) ||
|
||||||
|
item.AdministrativeClass.Name.Contains(classKeyword) ||
|
||||||
|
item.AdministrativeClass.Major!.Name.Contains(classKeyword)));
|
||||||
|
}
|
||||||
|
|
||||||
var total = await source.CountAsync(cancellationToken);
|
var total = await source.CountAsync(cancellationToken);
|
||||||
var items = await source
|
var items = await source
|
||||||
|
|||||||
Loaded 3 of 7 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user