|
@@ -15,15 +15,22 @@ class TeaplanService extends CrudService {
|
|
|
}
|
|
|
|
|
|
async findteacher({ batchid }) {
|
|
|
- const teaplans = await this.model.find();
|
|
|
- const headteachers = [];
|
|
|
- for (const teaplan of teaplans) {
|
|
|
- if (!teaplan.nobatchid.includes(batchid)) {
|
|
|
- const headteahcer = await this.hmodel.findById(teaplan.headteacherid);
|
|
|
- headteachers.push(headteahcer);
|
|
|
+ const headteachers = await this.hmodel.find();
|
|
|
+ const newheadteachers = [];
|
|
|
+ for (const headteacher of headteachers) {
|
|
|
+ const teaplan = await this.model.findOne({ headteacherid: headteacher.id });
|
|
|
+ if (teaplan) {
|
|
|
+ const nobatchids = teaplan.nobatchid;
|
|
|
+ if (nobatchids.includes(batchid)) {
|
|
|
+ newheadteachers.push({ ...JSON.parse(JSON.stringify(headteacher)), status: '0' });
|
|
|
+ } else {
|
|
|
+ newheadteachers.push(headteacher);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ newheadteachers.push(headteacher);
|
|
|
}
|
|
|
}
|
|
|
- return headteachers;
|
|
|
+ return newheadteachers;
|
|
|
}
|
|
|
|
|
|
}
|