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 UploadtaskService extends CrudService {
- constructor(ctx) {
- super(ctx, 'uploadtask');
- this.model = this.ctx.model.Uploadtask;
- this.stumodel = this.ctx.model.Student;
- }
- async query({ skip, limit, ...info }) {
- const total = await this.model.count(info);
- const res = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
- const data = [];
- for (const elm of res) {
- const _elm = _.cloneDeep(JSON.parse(JSON.stringify(elm)));
- const stu = await this.stumodel.findById(_elm.studentid);
- _elm.stuname = stu.name;
- data.push(_elm);
- }
- return { data, total };
- }
- }
- module.exports = UploadtaskService;
|