123456789101112131415161718192021222324252627282930313233 |
- 'use strict';
- const assert = require('assert');
- const _ = require('lodash');
- const { ObjectId } = require('mongoose').Types;
- const { CrudService } = require('naf-framework-mongoose/lib/service');
- const { BusinessError, ErrorCode } = require('naf-core').Error;
- class ApplyService extends CrudService {
- constructor(ctx) {
- super(ctx, 'apply');
- this.model = this.ctx.model.Apply;
- this.tmodel = this.ctx.model.Teacher;
- }
- // 查询
- async queryteacher(num) {
- console.log(num);
- const { termid, subid } = num;
- const data = await this.model.find({ termid, subid }).sort({ msscore: -1 });
- const teachers = [];
- for (const _data of data) {
- const teacherid = _data.teacherid;
- const teacher = await this.tmodel.findById(teacherid);
- teachers.push(teacher);
- }
- return teachers;
- }
- }
- module.exports = ApplyService;
|