优化条件筛选
This commit is contained in:
1 parent
eb20211f0e
commit
130bffbd01
6 files changed
+152
-1
No files matched your search
@@ -237,6 +237,10 @@ public sealed class BaseDataController(AppDbContext db, IAppCache cache) : Contr
|
||||
int? page,
|
||||
int? pageSize,
|
||||
string? keyword,
|
||||
Guid? collegeId,
|
||||
Guid? majorId,
|
||||
int? grade,
|
||||
bool? isEnabled,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (page.HasValue || pageSize.HasValue)
|
||||
@@ -245,6 +249,11 @@ public sealed class BaseDataController(AppDbContext db, IAppCache cache) : Contr
|
||||
return ValidationProblem("页码必须大于 0,且每页条数应在 1 至 100 之间。");
|
||||
|
||||
var source = db.AdministrativeClasses.AsNoTracking();
|
||||
if (collegeId.HasValue)
|
||||
source = source.Where(x => x.Major!.CollegeId == collegeId.Value);
|
||||
if (majorId.HasValue) source = source.Where(x => x.MajorId == majorId.Value);
|
||||
if (grade.HasValue) source = source.Where(x => x.Grade == grade.Value);
|
||||
if (isEnabled.HasValue) source = source.Where(x => x.IsEnabled == isEnabled.Value);
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
keyword = keyword.Trim();
|
||||
@@ -511,6 +520,11 @@ public sealed class BaseDataController(AppDbContext db, IAppCache cache) : Contr
|
||||
int? page,
|
||||
int? pageSize,
|
||||
string? keyword,
|
||||
Guid? campusId,
|
||||
Guid? buildingId,
|
||||
int? minimumCapacity,
|
||||
TeachingVenueNature? teachingVenueNature,
|
||||
bool? isEnabled,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (page.HasValue || pageSize.HasValue)
|
||||
@@ -519,6 +533,14 @@ public sealed class BaseDataController(AppDbContext db, IAppCache cache) : Contr
|
||||
return ValidationProblem("页码必须大于 0,且每页条数应在 1 至 100 之间。");
|
||||
|
||||
var source = db.Classrooms.AsNoTracking();
|
||||
if (campusId.HasValue)
|
||||
source = source.Where(x => x.Building!.CampusId == campusId.Value);
|
||||
if (buildingId.HasValue) source = source.Where(x => x.BuildingId == buildingId.Value);
|
||||
if (minimumCapacity.HasValue)
|
||||
source = source.Where(x => x.Capacity >= minimumCapacity.Value);
|
||||
if (teachingVenueNature.HasValue)
|
||||
source = source.Where(x => (x.TeachingVenueNature & teachingVenueNature.Value) != 0);
|
||||
if (isEnabled.HasValue) source = source.Where(x => x.IsEnabled == isEnabled.Value);
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
keyword = keyword.Trim();
|
||||
|
||||
Reference in new issue
Block a user