|
@@ -149,6 +149,7 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
//获取老师详细信息
|
|
|
HashSet<string> info = new HashSet<string>();
|
|
|
+ HashSet<string> room = new HashSet<string>();
|
|
|
foreach (CourseDto dto in sc)
|
|
|
{
|
|
|
if (dto.course != null)
|
|
@@ -161,13 +162,15 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
info.Add(schedule.teacherId);
|
|
|
}
|
|
|
+ if (!string.IsNullOrEmpty(schedule.room))
|
|
|
+ {
|
|
|
+ room.Add(schedule.room);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
- return Ok(new { courses = sc});
|
|
|
- }
|
|
|
}
|
|
|
+ //处理教师基础信息
|
|
|
List<(string id, string name)> teachers = new();
|
|
|
if (info.Count > 0)
|
|
|
{
|
|
@@ -186,9 +189,28 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //处理教室基础信息
|
|
|
+ List<(string id, string name)> rooms = new();
|
|
|
+ if (room.Count > 0)
|
|
|
+ {
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
|
|
|
+ queryText: $"select c.id,c.name from c where c.id in ({ string.Join(",", room.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Room-{school}") }))
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
+ {
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ rooms.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
var courses = sc.Select(s => new
|
|
|
{
|
|
|
- course = new
|
|
|
+ course = s.course != null ? new
|
|
|
{
|
|
|
id = s.course.id,
|
|
|
name = s.course.name,
|
|
@@ -203,6 +225,7 @@ namespace TEAMModelOS.Controllers
|
|
|
schedule = s.course.schedule.Select(c => new
|
|
|
{
|
|
|
room = c.room,
|
|
|
+ roomName = rooms.FirstOrDefault(t => t.id == c.room).name,
|
|
|
classId = c.classId,
|
|
|
notice = c.notice,
|
|
|
teacherId = c.teacherId,
|
|
@@ -210,7 +233,7 @@ namespace TEAMModelOS.Controllers
|
|
|
time = c.time,
|
|
|
stulist = c.stulist
|
|
|
})
|
|
|
- },
|
|
|
+ } : null,
|
|
|
s.stuCourse
|
|
|
});
|
|
|
return Ok(new { courses });
|