Browse Source

修改班主任全年计划表中根据批次id查询所有班主任接口

reloaded 5 years ago
parent
commit
6e56317a44
2 changed files with 16 additions and 7 deletions
  1. 2 0
      app/service/class.js
  2. 14 7
      app/service/teaplan.js

+ 2 - 0
app/service/class.js

@@ -62,8 +62,10 @@ class ClassService extends CrudService {
 
   async notice(data) {
     for (const classid of data.classids) {
+      // 根据班级id找到需要通知的班级
       const _class = await this.model.findById(classid);
       const { headteacherid } = _class;
+      // 根据班级id找到对应的课程表
       const lesson = await this.lessmodel.findOne({ classid });
       if (lesson) {
         const lessons = lesson.lessons;

+ 14 - 7
app/service/teaplan.js

@@ -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;
   }
 
 }