lrf402788946 4 gadi atpakaļ
vecāks
revīzija
f938772597
2 mainītis faili ar 6 papildinājumiem un 5 dzēšanām
  1. 5 4
      app/controller/student.js
  2. 1 1
      app/service/student.js

+ 5 - 4
app/controller/student.js

@@ -12,10 +12,11 @@ class StudentController extends Controller {
     this.service = this.ctx.service.student;
   }
 
-  // async index() {
-  //   const data = await this.service.query(this.ctx.query);
-  //   this.ctx.ok({ ...data });
-  // }
+  async index() {
+    const { data } = await this.service.query(this.ctx.query);
+    const count = await this.service.count(this.ctx.query);
+    this.ctx.ok({ ...data, total: count });
+  }
 
   // GET
   // 查询

+ 1 - 1
app/service/student.js

@@ -113,7 +113,7 @@ class StudentService extends CrudService {
         stu.planid = _id;
       }
     }
-    return data;
+    return { data };
   }
 
   async count({ name, ...info }) {