1234567891011121314151617181920212223242526272829303132 |
- '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(query) {
- const { termid, subid, date } = query;
- const data = await this.model.find({ termid, subid, date }).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;
|