|
@@ -89,12 +89,17 @@ class GroupService extends CrudService {
|
|
|
const res = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
|
|
|
const data = [];
|
|
|
for (const _group of res) {
|
|
|
- const group = _.cloneDeep(JSON.parse(JSON.stringify(_group)));
|
|
|
- for (const stu of group.students) {
|
|
|
- const student = await this.smodel.findOne({ id: stu.stuid });
|
|
|
- if (student) stu.job = student.job;
|
|
|
+ const stus = [];
|
|
|
+ for (const stu of _group.students) {
|
|
|
+ const student = await this.smodel.findById(stu.stuid);
|
|
|
+ let job = '';
|
|
|
+ if (student) {
|
|
|
+ job = student.job;
|
|
|
+ }
|
|
|
+ stus.push({ ...JSON.parse(JSON.stringify(stu)), job });
|
|
|
}
|
|
|
- data.push(group);
|
|
|
+ _group.students = stus;
|
|
|
+ data.push(_group);
|
|
|
}
|
|
|
return { total, data };
|
|
|
}
|