|
@@ -37,14 +37,14 @@ namespace TEAMModelOS.Controllers
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
// 班级编码
|
|
|
if (request.@params.TryGetValue("classroomCode", out object classroomCode)
|
|
|
- ///学校编码
|
|
|
+ ///学校编码
|
|
|
&& request.@params.TryGetValue("schoolCode", out object schoolCode)
|
|
|
)
|
|
|
{
|
|
|
- List<ClassStudent> classroomStudents = await _cosmos.FindByDict<ClassStudent>(new Dictionary<string, object> { { "id", classroomCode }});
|
|
|
+ List<ClassStudent> classroomStudents = await _cosmos.FindByDict<ClassStudent>(new Dictionary<string, object> { { "id", classroomCode } });
|
|
|
List<Student> students = await _cosmos.FindByDict<Student>(
|
|
|
new Dictionary<string, object>() { { "classroomCode", classroomCode }, { "code", schoolCode } },
|
|
|
- new List<string> { "id","name","code", "seatNo", "studentId", "classroomCode" });
|
|
|
+ new List<string> { "id", "name", "code", "seatNo", "studentId", "classroomCode" });
|
|
|
List<dynamic> stus = new List<dynamic>();
|
|
|
List<ClassStudent> newClassStudents = new List<ClassStudent>();
|
|
|
///新增的学生
|
|
@@ -52,7 +52,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
students.ForEach(x =>
|
|
|
{
|
|
|
- if (!classroomStudents.Select(m=>m.code).Contains(x.studentId))
|
|
|
+ if (!classroomStudents.Select(m => m.code).Contains(x.studentId))
|
|
|
{
|
|
|
newClassStudents.Add(new ClassStudent() { id = x.classroomCode, code = x.studentId });
|
|
|
}
|
|
@@ -60,33 +60,40 @@ namespace TEAMModelOS.Controllers
|
|
|
stus.Add(stu);
|
|
|
});
|
|
|
}
|
|
|
- ///反射已存在的id信息
|
|
|
+ ///反射已存在的id信息
|
|
|
if (classroomStudents.IsNotEmpty())
|
|
|
{
|
|
|
///处理冗余的id查询
|
|
|
List<string> ids = new List<string>();
|
|
|
- classroomStudents.ForEach(x=> {
|
|
|
- if (!students.Select(m => m.studentId).Contains(x.code)) {
|
|
|
+ classroomStudents.ForEach(x =>
|
|
|
+ {
|
|
|
+ if (!students.Select(m => m.studentId).Contains(x.code))
|
|
|
+ {
|
|
|
ids.Add(x.code);
|
|
|
}
|
|
|
});
|
|
|
var sts = await _cosmos.FindByDict<Student>(new Dictionary<string, object>() { { "studentId", ids.ToArray() } });
|
|
|
- if(sts.IsNotEmpty())
|
|
|
+ if (sts.IsNotEmpty())
|
|
|
{
|
|
|
- sts.ForEach(x => {
|
|
|
+ sts.ForEach(x =>
|
|
|
+ {
|
|
|
var stu = new { x.id, x.name, x.code, x.seatNo, x.studentId, x.classroomCode };
|
|
|
stus.Add(stu);
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
//保存新增学生
|
|
|
- if (newClassStudents.IsNotEmpty()) {
|
|
|
- classroomStudents.AddRange( await _cosmos.SaveOrUpdateAll(newClassStudents));
|
|
|
+ if (newClassStudents.IsNotEmpty())
|
|
|
+ {
|
|
|
+ classroomStudents.AddRange(await _cosmos.SaveOrUpdateAll(newClassStudents));
|
|
|
}
|
|
|
return builder.Data(classroomStudents).Extend(new Dictionary<string, object> { { "students", stus }, { "count", stus.Count } }).build();
|
|
|
}
|
|
|
- else { throw new BizException("参数异常classroomCode,code", ResponseCode.PARAMS_ERROR); }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return builder.Error(ResponseCode.PARAMS_ERROR, "参数异常classroomCode,code!").build();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|