|
@@ -139,24 +139,31 @@ class ClassService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async query({ skip, limit, ...info }) {
|
|
|
+ const classes = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
|
|
|
+ const data = [];
|
|
|
+ for (const _class of classes) {
|
|
|
+ const classInfo = await this.fetch({ id: _class.id });
|
|
|
+ data.push(classInfo);
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
async fetch({ id }) {
|
|
|
- const classInfo = await this.model.findById(id);
|
|
|
+ const classInfo = _.cloneDeep(JSON.parse(JSON.stringify(await this.model.findById(id))));
|
|
|
const trainplan = await this.tmodel.findById(classInfo.planid);
|
|
|
if (trainplan) {
|
|
|
const term = _.filter(trainplan.termnum, item => item.id === classInfo.termid);
|
|
|
if (term.length > 0) {
|
|
|
classInfo.term = term[0].term;
|
|
|
- console.log(classInfo.term);
|
|
|
const batch = _.filter(term[0].batchnum, item => item.id === classInfo.batchid);
|
|
|
if (batch.length > 0) {
|
|
|
classInfo.batch = batch[0].batch;
|
|
|
- classInfo.batchname = batch[0].name;
|
|
|
classInfo.startdate = batch[0].startdate;
|
|
|
classInfo.enddate = batch[0].enddate;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- console.log(classInfo.term);
|
|
|
return classInfo;
|
|
|
}
|
|
|
}
|