This commit is contained in:
SpecialX
2025-06-27 19:03:10 +08:00
parent 14fbe6397a
commit a21ca80782
57 changed files with 3872 additions and 611 deletions

View File

@@ -67,15 +67,13 @@ namespace TechHelper.Services
}
}
// 实现 IBaseService<ClassDto, int>.GetAllAsync
public async Task<ApiResponse> GetAllAsync(QueryParameter query)
{
try
{
var repository = _work.GetRepository<Class>();
// 构建查询条件 (可根据 QueryParameter.Search 进行筛选)
Func<IQueryable<Class>, IOrderedQueryable<Class>> orderBy = null; // 默认不排序
Func<IQueryable<Class>, IOrderedQueryable<Class>> orderBy = null;
if (query.Search != null && !string.IsNullOrWhiteSpace(query.Search))
{
// 在 Name 字段中进行模糊搜索
@@ -127,9 +125,22 @@ namespace TechHelper.Services
}
}
public Task<ApiResponse> GetClassStudents(ClassDto classDto)
public async Task<ApiResponse> GetClassStudents(ClassDto classDto)
{
throw new NotImplementedException();
try
{
var result = await _work.GetRepository<Class>().GetFirstOrDefaultAsync(predicate:
c => c.Grade == classDto.Grade && c.Number == classDto.Class,
include: i => i
.Include(c => c.ClassStudents)
.ThenInclude(cs => cs.Student));
return ApiResponse.Success(result: result.ClassStudents);
}
catch (Exception ex)
{
return ApiResponse.Error($"获取学生列表错误, {ex.Message}, {ex.InnerException}");
}
}
public async Task<ApiResponse> GetUserClass(Guid id)
@@ -185,9 +196,6 @@ namespace TechHelper.Services
var existingClass = await _work.GetRepository<Class>().GetFirstOrDefaultAsync(
predicate: (c => c.Number == user.ClassId && c.Grade == user.GradeId));
// finduser and usrinfo are redundant if they are for the same user.
// Let's just use usrinfo
// var finduser = await _userManager.FindByEmailAsync(user.User);
if (existingClass == null || usrinfo == null) // Simplified check
{