|
@@ -194,7 +194,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
return Ok(new { error = ResponseCode.DATA_EXIST, V = "班级编码已经存在!" });
|
|
return Ok(new { error = ResponseCode.DATA_EXIST, V = "班级编码已经存在!" });
|
|
}
|
|
}
|
|
- List<StudentSimple> studentSimples = new List<StudentSimple>();
|
|
|
|
|
|
+ /*List<StudentSimple> studentSimples = new List<StudentSimple>();
|
|
StringBuilder sql = new StringBuilder();
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append("select A0.id,A0.name,A0.no from c join A0 in c.students ");
|
|
sql.Append("select A0.id,A0.name,A0.no from c join A0 in c.students ");
|
|
Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
@@ -212,7 +212,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- classroom.students = studentSimples;
|
|
|
|
|
|
+ classroom.students = studentSimples;*/
|
|
|
|
|
|
List<TeacherCourse> course = new List<TeacherCourse>();
|
|
List<TeacherCourse> course = new List<TeacherCourse>();
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.classes where A0.id = '{classroom.id}'"))
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c join A0 in c.classes where A0.id = '{classroom.id}'"))
|
|
@@ -295,20 +295,35 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- Class classroom = new Class();
|
|
|
|
|
|
+ List<Student> students = new List<Student>();
|
|
|
|
+ if (!requert.TryGetProperty("students", out JsonElement stus)) return BadRequest();
|
|
|
|
+ students = stus.ToObject<List<Student>>();
|
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
|
+ foreach (Student stu in students) {
|
|
|
|
+ var response = await client.GetContainer("TEAMModelOS", "Student").ReadItemStreamAsync(stu.id, new PartitionKey($"{stu.code}"));
|
|
|
|
+ if (response.Status == 200)
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
+ Student stuInfo = json.ToObject<Student>();
|
|
|
|
+ stuInfo.groupId = stu.groupId;
|
|
|
|
+ stuInfo.groupName = stu.groupName;
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(stuInfo, stuInfo.id, new PartitionKey($"{stuInfo.code}"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /*Class classroom = new Class();
|
|
if (!requert.TryGetProperty("classroom", out JsonElement room)) return BadRequest();
|
|
if (!requert.TryGetProperty("classroom", out JsonElement room)) return BadRequest();
|
|
//if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
//if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
classroom = room.ToObject<Class>();
|
|
classroom = room.ToObject<Class>();
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
+
|
|
var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classroom.id, new PartitionKey($"{classroom.code}"));
|
|
var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classroom.id, new PartitionKey($"{classroom.code}"));
|
|
if (sresponse.Status == 200)
|
|
if (sresponse.Status == 200)
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
Class classroom1 = json.ToObject<Class>();
|
|
Class classroom1 = json.ToObject<Class>();
|
|
- classroom1.students = classroom.students;
|
|
|
|
|
|
+ //classroom1.students = classroom.students;
|
|
var response = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom1, classroom1.id, new PartitionKey($"{classroom.code}"));
|
|
var response = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync(classroom1, classroom1.id, new PartitionKey($"{classroom.code}"));
|
|
- }
|
|
|
|
- return Ok(new { classroom });
|
|
|
|
|
|
+ }*/
|
|
|
|
+ return Ok(new { students });
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|