reloaded 4 years ago
parent
commit
8a00696418
1 changed files with 6 additions and 3 deletions
  1. 6 3
      app/service/student.js

+ 6 - 3
app/service/student.js

@@ -133,20 +133,23 @@ class StudentService extends CrudService {
 
   // 根据班级id查出班级各个学生的分数
   async findscore({ skip, limit, ...info }) {
+    const { classid } = info;
     const total = await this.model.count(info);
     const students = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
     const data = [];
+    const groups = await this.gmodel.find({ classid });
     for (const student of students) {
-      const _student = _.cloneDeep(student);
-      const groups = await this.gmodel.find({ classid: _student.classid });
+      const _student = JSON.parse(JSON.stringify(student));
       const group = groups.find(item => item.students.find(stuinfo => stuinfo.stuid === _student.id));
-      if (group && group.score) {
+      console.log(group);
+      if (group) {
         _student.groupscore = group.score;
       }
       const tasks = await this.upmodel.find({ studentid: _student.id });
       _student.tasks = tasks;
       data.push(_student);
     }
+
     return { total, data };
   }
 }