|
@@ -396,160 +396,153 @@ namespace TEAMModelOS.Controllers
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
List<object> stus = new List<object>();
|
|
List<object> stus = new List<object>();
|
|
List<string> stuIds = new List<string>();
|
|
List<string> stuIds = new List<string>();
|
|
-
|
|
|
|
|
|
+ string info = "";
|
|
for (int i = 0; i < ids.GetArrayLength(); i++)
|
|
for (int i = 0; i < ids.GetArrayLength(); i++)
|
|
{
|
|
{
|
|
- List<object> scList = new List<object>();
|
|
|
|
- List<object> suList = new List<object>();
|
|
|
|
- List<(string id, string name, string pic, string code, string classId,string className, string groupId, string groupName, string no)> listStudent = new List<(string id, string name, string pic, string code, string classId, string className, string groupId, string groupName, string no)>();
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(
|
|
|
|
- queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.classId = '{ids[i].GetString()}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
|
|
|
|
- {
|
|
|
|
- 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;
|
|
|
|
- stuIds.Add(account.GetProperty("id").GetString());
|
|
|
|
- var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(account.GetProperty("classId").GetString(), new PartitionKey($"Class-{schoolId}"));
|
|
|
|
- string className = "";
|
|
|
|
- if (response.Status == 200)
|
|
|
|
|
|
+ //ids.Add(id[i].ToJsonString());
|
|
|
|
+ info += ids[i].ToJsonString() + ",";
|
|
|
|
+ }
|
|
|
|
+ List<object> scList = new List<object>();
|
|
|
|
+ List<object> suList = new List<object>();
|
|
|
|
+ List<(string id, string name, string pic, string code, string classId ,string groupId, string groupName, string no)> listStudent = new List<(string id, string name, string pic, string code, string classId, string groupId, string groupName, string no)>();
|
|
|
|
+ //var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(ids[i].GetString(), new PartitionKey($"Class-{schoolId}"));
|
|
|
|
+ string className = "";
|
|
|
|
+ /* if (response.Status == 200)
|
|
{
|
|
{
|
|
using var document = await JsonDocument.ParseAsync(response.ContentStream);
|
|
using var document = await JsonDocument.ParseAsync(response.ContentStream);
|
|
Class @class = document.ToObject<Class>();
|
|
Class @class = document.ToObject<Class>();
|
|
className = @class.name;
|
|
className = @class.name;
|
|
- }
|
|
|
|
- listStudent.Add((account.GetProperty("id").GetString(),
|
|
|
|
- account.GetProperty("name").GetString(),
|
|
|
|
- account.GetProperty("picture").GetString(),
|
|
|
|
- account.GetProperty("code").GetString(),
|
|
|
|
- account.GetProperty("classId").GetString(),
|
|
|
|
- className,
|
|
|
|
- account.GetProperty("groupId").GetString(),
|
|
|
|
- account.GetProperty("groupName").GetString(),
|
|
|
|
- account.GetProperty("no").GetString()));
|
|
|
|
- }
|
|
|
|
- var scinfos = listStudent.Select(o =>
|
|
|
|
- new
|
|
|
|
- {
|
|
|
|
- o.id,
|
|
|
|
- o.name,
|
|
|
|
- o.pic,
|
|
|
|
- o.code,
|
|
|
|
- o.classId,
|
|
|
|
- o.className,
|
|
|
|
- o.groupId,
|
|
|
|
- o.groupName,
|
|
|
|
- o.no
|
|
|
|
- });
|
|
|
|
- scList.AddRange(scinfos);
|
|
|
|
- stus.Add(scList);
|
|
|
|
|
|
+ }*/
|
|
|
|
+ List<(string id, string name)> listClassList = new List<(string id,string name)>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
|
|
|
|
+ queryText: $"select c.id,c.name from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{schoolId}") }))
|
|
|
|
+ {
|
|
|
|
+ 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;
|
|
|
|
+ listClassList.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
|
|
|
|
+ //stuIds.Add(account.GetProperty("id").GetString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- List<(string id, string code, string stuId,string name)> listStuList = new List<(string id, string code, string stuId,string name)> ();
|
|
|
|
- if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
+ }
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(
|
|
|
|
+ queryText: $"select c.id,c.name,c.classId,c.code,c.groupId,c.groupName,c.no,c.picture from c where c.classId in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{schoolId}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
- List<StuList> stuLists = new List<StuList>();
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{ids[i].GetString()}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
|
|
|
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
|
+ while (accounts.MoveNext())
|
|
{
|
|
{
|
|
- stuLists.Add(item);
|
|
|
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
|
+ stuIds.Add(account.GetProperty("id").GetString());
|
|
|
|
+
|
|
|
|
+ listStudent.Add((account.GetProperty("id").GetString(),
|
|
|
|
+ account.GetProperty("name").GetString(),
|
|
|
|
+ account.GetProperty("picture").GetString(),
|
|
|
|
+ account.GetProperty("code").GetString(),
|
|
|
|
+ account.GetProperty("classId").GetString(),
|
|
|
|
+ account.GetProperty("groupId").GetString(),
|
|
|
|
+ account.GetProperty("groupName").GetString(),
|
|
|
|
+ account.GetProperty("no").GetString()));
|
|
}
|
|
}
|
|
- if (stuLists.Count > 0)
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var scinfos = listStudent.Select(o =>
|
|
|
|
+ new
|
|
|
|
+ {
|
|
|
|
+ o.id,
|
|
|
|
+ o.name,
|
|
|
|
+ o.pic,
|
|
|
|
+ o.code,
|
|
|
|
+ o.classId,
|
|
|
|
+ className = listClassList.FirstOrDefault(c => c.id == o.classId).name,
|
|
|
|
+ o.groupId,
|
|
|
|
+ o.groupName,
|
|
|
|
+ o.no
|
|
|
|
+ });
|
|
|
|
+ scList.AddRange(scinfos);
|
|
|
|
+ stus.Add(scList);
|
|
|
|
+ List<(string id, string code, string stuId, string name)> listStuList = new List<(string id, string code, string stuId, string name)>();
|
|
|
|
+ if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
|
+ {
|
|
|
|
+ List<StuList> stuLists = new List<StuList>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{schoolId}") }))
|
|
|
|
+ {
|
|
|
|
+ stuLists.Add(item);
|
|
|
|
+ }
|
|
|
|
+ if (stuLists.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (StuList stuList in stuLists)
|
|
{
|
|
{
|
|
- foreach (StuList stuList in stuLists)
|
|
|
|
|
|
+ foreach (Students stu in stuList.students)
|
|
{
|
|
{
|
|
- foreach (Students stu in stuList.students)
|
|
|
|
- {
|
|
|
|
- if (stu.code.Contains(schoolId.GetString()))
|
|
|
|
- {
|
|
|
|
- if (!stuIds.Contains(stu.id))
|
|
|
|
- {
|
|
|
|
- listStuList.Add((stu.id,
|
|
|
|
- stu.code,
|
|
|
|
- stuList.id,
|
|
|
|
- stuList.name));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- listStuList.Add((stu.id,
|
|
|
|
- stu.code,
|
|
|
|
- stuList.id,
|
|
|
|
- stuList.name));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ listStuList.Add((stu.id,
|
|
|
|
+ stu.code,
|
|
|
|
+ stuList.id,
|
|
|
|
+ stuList.name));
|
|
}
|
|
}
|
|
- var infos = listStuList.Select(o =>
|
|
|
|
- new
|
|
|
|
- {
|
|
|
|
- o.id,
|
|
|
|
- o.code,
|
|
|
|
- o.stuId,
|
|
|
|
- o.name
|
|
|
|
- });
|
|
|
|
- suList.AddRange(infos);
|
|
|
|
- stus.Add(suList);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ var infos = listStuList.Select(o =>
|
|
|
|
+ new
|
|
|
|
+ {
|
|
|
|
+ o.id,
|
|
|
|
+ o.code,
|
|
|
|
+ o.stuId,
|
|
|
|
+ o.name
|
|
|
|
+ });
|
|
|
|
+ suList.AddRange(infos);
|
|
|
|
+ stus.Add(suList);
|
|
}
|
|
}
|
|
- else {
|
|
|
|
- //处理发布对象为自选名单(个人)
|
|
|
|
- List<StuList> stuLists1 = new List<StuList>();
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{ids[i].GetString()}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
|
- {
|
|
|
|
- stuLists1.Add(item);
|
|
|
|
- }
|
|
|
|
- if (stuLists1.Count > 0)
|
|
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //处理发布对象为自选名单(个人)
|
|
|
|
+ List<StuList> stuLists1 = new List<StuList>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
|
+ {
|
|
|
|
+ stuLists1.Add(item);
|
|
|
|
+ }
|
|
|
|
+ if (stuLists1.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (StuList stuList in stuLists1)
|
|
{
|
|
{
|
|
- foreach (StuList stuList in stuLists1)
|
|
|
|
|
|
+ foreach (Students students in stuList.students)
|
|
{
|
|
{
|
|
- foreach (Students students in stuList.students)
|
|
|
|
|
|
+
|
|
|
|
+ listStuList.Add((students.id,
|
|
|
|
+ students.code,
|
|
|
|
+ stuList.id,
|
|
|
|
+ stuList.name));
|
|
|
|
+ }
|
|
|
|
+ if (stuList.tmids.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (string tid in stuList.tmids)
|
|
{
|
|
{
|
|
- if (students.code.Contains(schoolId.GetString()))
|
|
|
|
- {
|
|
|
|
- if (!stuIds.Contains(students.id))
|
|
|
|
- {
|
|
|
|
- listStuList.Add((students.id,
|
|
|
|
- students.code,
|
|
|
|
- stuList.id,
|
|
|
|
- stuList.name));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- listStuList.Add((students.id,
|
|
|
|
- students.code,
|
|
|
|
- stuList.id,
|
|
|
|
- stuList.name));
|
|
|
|
- }
|
|
|
|
|
|
+ listStuList.Add((tid,
|
|
|
|
+ default,
|
|
|
|
+ stuList.id,
|
|
|
|
+ stuList.name));
|
|
}
|
|
}
|
|
- if (stuList.tmids.Count > 0)
|
|
|
|
- {
|
|
|
|
- foreach (string tid in stuList.tmids)
|
|
|
|
- {
|
|
|
|
- listStuList.Add((tid,
|
|
|
|
- default,
|
|
|
|
- stuList.id,
|
|
|
|
- stuList.name));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- var infos = listStuList.Select(o =>
|
|
|
|
- new
|
|
|
|
- {
|
|
|
|
- o.id,
|
|
|
|
- o.code,
|
|
|
|
- o.stuId,
|
|
|
|
- o.name
|
|
|
|
- });
|
|
|
|
- suList.AddRange(infos);
|
|
|
|
- stus.Add(suList);
|
|
|
|
}
|
|
}
|
|
|
|
+ var infos = listStuList.Select(o =>
|
|
|
|
+ new
|
|
|
|
+ {
|
|
|
|
+ o.id,
|
|
|
|
+ o.code,
|
|
|
|
+ o.stuId,
|
|
|
|
+ o.name
|
|
|
|
+ });
|
|
|
|
+ suList.AddRange(infos);
|
|
|
|
+ stus.Add(suList);
|
|
}
|
|
}
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
return Ok(new { stus });
|
|
return Ok(new { stus });
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|