reloaded 5 years ago
parent
commit
0179c9b328
3 changed files with 10 additions and 9 deletions
  1. 0 5
      app/controller/class.js
  2. 0 1
      app/router.js
  3. 10 3
      app/service/class.js

+ 0 - 5
app/controller/class.js

@@ -35,11 +35,6 @@ class ClassController extends Controller {
     );
     this.ctx.ok({ data: res });
   }
-
-  async searchDate() {
-    const res = await this.service.searchDate(this.ctx.query);
-    this.ctx.ok({ data: res });
-  }
 }
 
 module.exports = CrudController(ClassController, meta);

+ 0 - 1
app/router.js

@@ -53,7 +53,6 @@ module.exports = app => {
   router.post('bedroom', '/api/train/bedroom/ibeacon', controller.bedroom.ibeacon);
 
   // 班级表设置路由
-  router.get('class', '/api/train/class/searchDate', controller.class.searchDate);
   router.post('class', '/api/train/class/notice', controller.class.notice);
   router.resources('class', '/api/train/class', controller.class); // index、create、show、destroy
   router.post('class', '/api/train/class/update/:id', controller.class.update);

+ 10 - 3
app/service/class.js

@@ -139,18 +139,25 @@ class ClassService extends CrudService {
     }
   }
 
-  async searchDate({ classid }) {
-    const classInfo = await this.model.findById(classid);
+  async fetch({ id }) {
+    const classInfo = 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) {
-          return { startdate: batch[0].startdate, enddate: batch[0].enddate };
+          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;
   }
 }