apply.js 863 B

1234567891011121314151617181920212223242526272829303132
  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 ApplyService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'apply');
  10. this.model = this.ctx.model.Apply;
  11. this.tmodel = this.ctx.model.Teacher;
  12. }
  13. // 查询
  14. async queryteacher(query) {
  15. const { termid, subid, date } = query;
  16. const data = await this.model.find({ termid, subid, date }).sort({ msscore: -1 });
  17. const teachers = [];
  18. for (const _data of data) {
  19. const teacherid = _data.teacherid;
  20. const teacher = await this.tmodel.findById(teacherid);
  21. teachers.push(teacher);
  22. }
  23. return teachers;
  24. }
  25. }
  26. module.exports = ApplyService;