Browse Source

新增查询某批次能上课的所有班主任信息的接口

reloaded 5 năm trước cách đây
mục cha
commit
0d85a3b5f3
3 tập tin đã thay đổi với 19 bổ sung0 xóa
  1. 5 0
      app/controller/teaplan.js
  2. 1 0
      app/router.js
  3. 13 0
      app/service/teaplan.js

+ 5 - 0
app/controller/teaplan.js

@@ -13,6 +13,11 @@ class TeaplanController extends Controller {
     this.service = this.ctx.service.teaplan;
   }
 
+  async findteacher() {
+    const data = await this.service.findteacher(this.ctx.query);
+    this.ctx.ok({ data });
+  }
+
 
 }
 

+ 1 - 0
app/router.js

@@ -77,6 +77,7 @@ module.exports = app => {
   router.post('schtime', '/api/train/schtime/update/:id', controller.schtime.update);
 
   // 班主任全年计划表设置路由
+  router.get('teaplan', '/api/train/teaplan/findteacher', controller.teaplan.findteacher);
   router.resources('teaplan', '/api/train/teaplan', controller.teaplan); // index、create、show、destroy
   router.post('teaplan', '/api/train/teaplan/update/:id', controller.teaplan.update);
 

+ 13 - 0
app/service/teaplan.js

@@ -11,6 +11,19 @@ class TeaplanService extends CrudService {
   constructor(ctx) {
     super(ctx, 'teaplan');
     this.model = this.ctx.model.Teaplan;
+    this.hmodel = this.ctx.model.Headteacher;
+  }
+
+  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);
+      }
+    }
+    return headteachers;
   }
 
 }