年级班级
This commit is contained in:
parent
ce3991d082
commit
81e1533243
@ -550,12 +550,28 @@ namespace YD_YiLu.Api.Services.Impl
|
|||||||
.ToListAsync(); // ✅ 确保在此处完成
|
.ToListAsync(); // ✅ 确保在此处完成
|
||||||
|
|
||||||
// 7️⃣ 返回结果
|
// 7️⃣ 返回结果
|
||||||
|
var classIds = grouped
|
||||||
|
.Select(x => x.Key.ClassId ?? 0)
|
||||||
|
.Where(x => x > 0)
|
||||||
|
.Distinct()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var classMap = await _context.Class
|
||||||
|
.Where(x => classIds.Contains(x.Id))
|
||||||
|
.ToDictionaryAsync(x => x.Id, x => new
|
||||||
|
{
|
||||||
|
x.GradeName,
|
||||||
|
x.ClassName
|
||||||
|
});
|
||||||
|
|
||||||
return grouped.Select(x => new DeviceSyncGradeOrderItemDto
|
return grouped.Select(x => new DeviceSyncGradeOrderItemDto
|
||||||
{
|
{
|
||||||
UserId = x.Key.Id,
|
UserId = x.Key.Id,
|
||||||
Nickname = x.Key.StudentName,
|
Nickname = x.Key.StudentName,
|
||||||
OrganizationId = x.Key.ClassId ?? 0,
|
OrganizationId = x.Key.ClassId ?? 0,
|
||||||
OrganizationName = x.Key.ClassName ?? "",
|
OrganizationName = classMap.TryGetValue(x.Key.ClassId ?? 0, out var classInfo)
|
||||||
|
? $"{classInfo.GradeName ?? ""}{classInfo.ClassName ?? ""}"
|
||||||
|
: x.Key.ClassName ?? "",
|
||||||
Gender = x.Key.Sex,
|
Gender = x.Key.Sex,
|
||||||
Score = Math.Round(x.Score).ToString("0"),
|
Score = Math.Round(x.Score).ToString("0"),
|
||||||
CourseId = x.Key.CourseId,
|
CourseId = x.Key.CourseId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user