student.js 767 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. const assert = require('assert');
  3. const _ = require('lodash');
  4. const { ObjectId } = require('mongoose').Types;
  5. const { CrudService } = require('naf-framework-mongoose/lib/service');
  6. const { BusinessError, ErrorCode } = require('naf-core').Error;
  7. class StudentService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'student');
  10. this.model = this.ctx.model.Student;
  11. }
  12. // 查询
  13. async seek({ termid, skip, limit }) {
  14. const students = await this.model.find({ termid, classid: null });
  15. const data = await this.model.find({ termid, classid: null }).skip(Number(skip)).limit(Number(limit));
  16. const total = await students.length;
  17. const result = { total, data };
  18. return result;
  19. }
  20. }
  21. module.exports = StudentService;