student.js 704 B

1234567891011121314151617181920212223242526
  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 }).skip(Number(skip)).limit(Number(limit));
  15. const total = await students.length;
  16. const result = { total, students };
  17. return result;
  18. }
  19. }
  20. module.exports = StudentService;