|
@@ -41,7 +41,7 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
if (ValidateHelper.IsValid(request.@params))
|
|
|
{
|
|
|
List<ClassroomStudent> students = await _cosmos.SaveOrUpdateAll(request.@params);
|
|
|
-
|
|
|
+ builder.Data(students);
|
|
|
}
|
|
|
return builder.build();
|
|
|
}
|
|
@@ -56,45 +56,22 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
public async Task<BaseJosnRPCResponse> AddClassroomAsync(JosnRPCRequest<List<ClassroomStudent>> request)
|
|
|
{
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
- await NotRepeatSeat(request, builder);
|
|
|
-
|
|
|
- //if (ValidateHelper.IsValid(request.@params))
|
|
|
- //{
|
|
|
- // List<ClassroomStudent> students = request.@params;
|
|
|
- // List<ClassroomStudent> students1 = new List<ClassroomStudent>();
|
|
|
-
|
|
|
- // foreach (ClassroomStudent item in students) {
|
|
|
- // List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "classroomCode", item.classroomCode } });
|
|
|
- // if (classroomStudents.IsNotEmpty())
|
|
|
- // {
|
|
|
- // item.students.ForEach(
|
|
|
- // y =>
|
|
|
- // {
|
|
|
- // //标记是否 加入 学生数组中
|
|
|
- // bool fig = true;
|
|
|
- // classroomStudents[0].students.ForEach(
|
|
|
- // x =>
|
|
|
- // {
|
|
|
- // if (y.studentId == x.studentId)
|
|
|
- // {
|
|
|
- // x.seatNo = y.seatNo;
|
|
|
- // fig = false;
|
|
|
- // }
|
|
|
-
|
|
|
- // });
|
|
|
- // if (fig)
|
|
|
- // {
|
|
|
- // classroomStudents[0].students.Add(y);
|
|
|
- // }
|
|
|
- // });
|
|
|
- // ClassroomStudent students2 = await _cosmos.SaveOrUpdate(classroomStudents[0]);
|
|
|
- // students1.Add(students2);
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // //List<ClassroomStudent> students = await _cosmos.SaveOrUpdateAll(request.@params);
|
|
|
- // builder.Data(students1);
|
|
|
- //}
|
|
|
+
|
|
|
+ if (ValidateHelper.IsValid(request.@params))
|
|
|
+ {
|
|
|
+ List<ClassroomStudent> students = request.@params;
|
|
|
+ List<ClassroomStudent> classroomStudents1 = new List<ClassroomStudent>();
|
|
|
+ foreach (ClassroomStudent item1 in students) {
|
|
|
+ List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "id", item1.id } });
|
|
|
+ foreach (ClassroomStudent item2 in classroomStudents) {
|
|
|
+ item2.studentId.UnionWith(item1.studentId);
|
|
|
+ }
|
|
|
+ classroomStudents1.AddRange(classroomStudents);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ClassroomStudent> students1 = await _cosmos.SaveOrUpdateAll(classroomStudents1);
|
|
|
+ if (students1.Count > 0) builder.Data(students1);
|
|
|
+ }
|
|
|
return builder.build();
|
|
|
}
|
|
|
|
|
@@ -105,130 +82,135 @@ namespace TEAMModelOS.Controllers.Core
|
|
|
if (ValidateHelper.IsValid(request.@params))
|
|
|
{
|
|
|
List<ClassroomStudent> students = request.@params;
|
|
|
- List<ClassroomStudent> students1 = new List<ClassroomStudent>();
|
|
|
-
|
|
|
+ List<ClassroomStudent> classroomStudents1 = new List<ClassroomStudent>();
|
|
|
foreach (ClassroomStudent item1 in students)
|
|
|
{
|
|
|
- List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "classroomCode", item1.classroomCode } });
|
|
|
- if (classroomStudents.IsNotEmpty())
|
|
|
+ List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "id", item1.id } });
|
|
|
+ foreach (ClassroomStudent item2 in classroomStudents)
|
|
|
{
|
|
|
- List<Stu> item = new List<Stu>();
|
|
|
- item.AddRange(classroomStudents[0].students);
|
|
|
- item1.students.ForEach(y =>
|
|
|
- {
|
|
|
- classroomStudents[0].students.ForEach(x =>
|
|
|
- {
|
|
|
- if (y.studentId == x.studentId)
|
|
|
- {
|
|
|
- item.Remove(x);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- if (item.Count > 0) {
|
|
|
- classroomStudents[0].students = item;
|
|
|
- ClassroomStudent students2 = await _cosmos.SaveOrUpdate(classroomStudents[0]);
|
|
|
- students1.Add(students2);
|
|
|
- }
|
|
|
- else if (item.IsEmpty())
|
|
|
- {
|
|
|
- await _cosmos.DeleteAsync(classroomStudents[0]);
|
|
|
- //students1.Add(null);
|
|
|
- }
|
|
|
+ item2.studentId.ExceptWith(item1.studentId);
|
|
|
}
|
|
|
+ classroomStudents1.AddRange(classroomStudents);
|
|
|
}
|
|
|
- builder.Data(students1);
|
|
|
+
|
|
|
+ List<ClassroomStudent> students1 = await _cosmos.SaveOrUpdateAll(classroomStudents1);
|
|
|
+ if (students1.Count > 0) builder.Data(students1);
|
|
|
}
|
|
|
return builder.build();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- private async Task NotRepeatSeat(JosnRPCRequest<List<ClassroomStudent>> request, JsonRPCResponseBuilder builder)
|
|
|
+ [HttpPost("FindClassroom")]
|
|
|
+ public async Task<BaseJosnRPCResponse> DelClassroom(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
{
|
|
|
- List<ClassroomStudent> requestStudent = request.@params;
|
|
|
- List<ClassroomStudent> students1 = new List<ClassroomStudent>();
|
|
|
- List<dynamic> repeatStudent = new List<dynamic>();
|
|
|
-
|
|
|
- for (int s = 0; s < requestStudent.Count; s++)
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ if (ValidateHelper.IsValid(request.@params))
|
|
|
{
|
|
|
-
|
|
|
- List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "classroomCode", requestStudent[s].classroomCode } });
|
|
|
- Dictionary<int, object> seatNo = new Dictionary<int, object>();
|
|
|
- if (classroomStudents.IsNotEmpty())
|
|
|
- {
|
|
|
- // 数据库等待换位置学生序号
|
|
|
- List<Stu> awaitstudent = new List<Stu>();
|
|
|
-
|
|
|
- List<Stu> itemstu = new List<Stu>();
|
|
|
- itemstu.AddRange(classroomStudents[0].students);
|
|
|
- for (int x = 0; x < classroomStudents[0].students.Count; x++)
|
|
|
- {
|
|
|
- for (int y = 0; y < requestStudent[s].students.Count; y++)
|
|
|
- {
|
|
|
- if (requestStudent[s].students[y].studentId == classroomStudents[0].students[x].studentId)
|
|
|
- {
|
|
|
- itemstu.Remove(classroomStudents[0].students[x]);
|
|
|
- awaitstudent.Add(classroomStudents[0].students[x]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- foreach (Stu stu in itemstu)
|
|
|
- {
|
|
|
- seatNo.Add(stu.seatNo, stu.studentId);
|
|
|
- }
|
|
|
-
|
|
|
- for (int y = 0; y < requestStudent[s].students.Count; y++)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
-
|
|
|
- // 把 请求 学生加入座位队列
|
|
|
- seatNo.Add(requestStudent[s].students[y].seatNo, requestStudent[s].students[y].studentId);
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- //座位重复学生 加入数组
|
|
|
- var student = new { requestStudent[s].students[y].seatNo, requestStudent[s].students[y].studentId, classroomStudents[0].classroomCode };
|
|
|
- repeatStudent.Add(student);
|
|
|
-
|
|
|
- //回滚
|
|
|
- if (awaitstudent.IsNotEmpty())
|
|
|
- {
|
|
|
- foreach (Stu stu in awaitstudent) {
|
|
|
- if(requestStudent[s].students[y].studentId == stu.studentId)
|
|
|
- itemstu.Add(stu);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- //标记是否加入数据库查到的学生列表
|
|
|
- bool fig = true;
|
|
|
- itemstu.ForEach(x =>
|
|
|
- {
|
|
|
- if (x.studentId == requestStudent[s].students[y].studentId)
|
|
|
- {
|
|
|
- x.seatNo = requestStudent[s].students[y].seatNo;
|
|
|
- fig = false;
|
|
|
- }
|
|
|
- });
|
|
|
- if (fig) itemstu.Add(requestStudent[s].students[y]);
|
|
|
- }
|
|
|
- classroomStudents[0].students = itemstu;
|
|
|
-
|
|
|
- ClassroomStudent students = await _cosmos.SaveOrUpdate(classroomStudents[0]);
|
|
|
- students1.Add(students);
|
|
|
- }
|
|
|
+ List<ClassroomStudent> sc = await _cosmos.FindByDict<ClassroomStudent>(request.@params);
|
|
|
+ builder.Data(sc).Extend(new Dictionary<string, object> { { "count", sc.Count } });
|
|
|
+ //select value(c) from c join A0 in c.studentId where 1=1 and A0 = @studentId0
|
|
|
}
|
|
|
+ return builder.build();
|
|
|
+ }
|
|
|
|
|
|
- if (repeatStudent.Count > 0)
|
|
|
+
|
|
|
+ [HttpPost("FindStudents")]
|
|
|
+ public async Task<BaseJosnRPCResponse> FindStudents(JosnRPCRequest<string> studentId)
|
|
|
+ {
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ if (ValidateHelper.IsValid(studentId.@params))
|
|
|
{
|
|
|
- builder.Extend(new Dictionary<string, object> { { "repeatStudent", repeatStudent } });
|
|
|
+ List<ClassroomStudent> sc = await _cosmos.FindSQL<ClassroomStudent>("select c.id,c.scopeCode from c join A0 in c.studentId where 1=1 and A0 = \'" + studentId.@params + "\'");
|
|
|
+ //select value(c) from c join A0 in c.studentId where 1=1 and A0 = @studentId0
|
|
|
+ builder.Data(sc).Extend(new Dictionary<string, object> { { "count", sc.Count } });
|
|
|
}
|
|
|
- builder.Data(students1);
|
|
|
+ return builder.build();
|
|
|
}
|
|
|
+ //private async Task NotRepeatSeat(JosnRPCRequest<List<ClassroomStudent>> request, JsonRPCResponseBuilder builder)
|
|
|
+ //{
|
|
|
+ // List<ClassroomStudent> requestStudent = request.@params;
|
|
|
+ // List<ClassroomStudent> students1 = new List<ClassroomStudent>();
|
|
|
+ // List<dynamic> repeatStudent = new List<dynamic>();
|
|
|
+
|
|
|
+ // for (int s = 0; s < requestStudent.Count; s++)
|
|
|
+ // {
|
|
|
+
|
|
|
+ // List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "classroomCode", requestStudent[s].classroomCode } });
|
|
|
+ // Dictionary<int, object> seatNo = new Dictionary<int, object>();
|
|
|
+ // if (classroomStudents.IsNotEmpty())
|
|
|
+ // {
|
|
|
+ // // 数据库等待换位置学生序号
|
|
|
+ // List<Stu> awaitstudent = new List<Stu>();
|
|
|
+
|
|
|
+ // List<Stu> itemstu = new List<Stu>();
|
|
|
+ // itemstu.AddRange(classroomStudents[0].studentId);
|
|
|
+ // for (int x = 0; x < classroomStudents[0].studentId.Count; x++)
|
|
|
+ // {
|
|
|
+ // for (int y = 0; y < requestStudent[s].studentId.Count; y++)
|
|
|
+ // {
|
|
|
+ // if (requestStudent[s].studentId[y].studentId == classroomStudents[0].studentId[x].studentId)
|
|
|
+ // {
|
|
|
+ // itemstu.Remove(classroomStudents[0].studentId[x]);
|
|
|
+ // awaitstudent.Add(classroomStudents[0].studentId[x]);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // foreach (Stu stu in itemstu)
|
|
|
+ // {
|
|
|
+ // seatNo.Add(stu.seatNo, stu.studentId);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // for (int y = 0; y < requestStudent[s].studentId.Count; y++)
|
|
|
+ // {
|
|
|
+ // try
|
|
|
+ // {
|
|
|
+
|
|
|
+ // // 把 请求 学生加入座位队列
|
|
|
+ // seatNo.Add(requestStudent[s].studentId[y].seatNo, requestStudent[s].studentId[y].studentId);
|
|
|
+ // }
|
|
|
+ // catch
|
|
|
+ // {
|
|
|
+ // //座位重复学生 加入数组
|
|
|
+ // var student = new { requestStudent[s].studentId[y].seatNo, requestStudent[s].studentId[y].studentId, classroomStudents[0].classroomCode };
|
|
|
+ // repeatStudent.Add(student);
|
|
|
+
|
|
|
+ // //回滚
|
|
|
+ // if (awaitstudent.IsNotEmpty())
|
|
|
+ // {
|
|
|
+ // foreach (Stu stu in awaitstudent) {
|
|
|
+ // if(requestStudent[s].studentId[y].studentId == stu.studentId)
|
|
|
+ // itemstu.Add(stu);
|
|
|
+ // }
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // //标记是否加入数据库查到的学生列表
|
|
|
+ // bool fig = true;
|
|
|
+ // itemstu.ForEach(x =>
|
|
|
+ // {
|
|
|
+ // if (x.studentId == requestStudent[s].studentId[y].studentId)
|
|
|
+ // {
|
|
|
+ // x.seatNo = requestStudent[s].studentId[y].seatNo;
|
|
|
+ // fig = false;
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // if (fig) itemstu.Add(requestStudent[s].studentId[y]);
|
|
|
+ // }
|
|
|
+ // classroomStudents[0].studentId = itemstu;
|
|
|
+
|
|
|
+ // ClassroomStudent students = await _cosmos.SaveOrUpdate(classroomStudents[0]);
|
|
|
+ // students1.Add(students);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (repeatStudent.Count > 0)
|
|
|
+ // {
|
|
|
+ // builder.Extend(new Dictionary<string, object> { { "repeatStudent", repeatStudent } });
|
|
|
+ // }
|
|
|
+ // builder.Data(students1);
|
|
|
+ //}
|
|
|
|
|
|
}
|
|
|
}
|