apply.js 869 B

123456789101112131415161718192021222324252627282930313233
  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(num) {
  15. console.log(num);
  16. const { termid, subid } = num;
  17. const data = await this.model.find({ termid, subid }).sort({ msscore: -1 });
  18. const teachers = [];
  19. for (const _data of data) {
  20. const teacherid = _data.teacherid;
  21. const teacher = await this.tmodel.findById(teacherid);
  22. teachers.push(teacher);
  23. }
  24. return teachers;
  25. }
  26. }
  27. module.exports = ApplyService;