'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 GroupscoreService extends CrudService { constructor(ctx) { super(ctx, 'groupscore'); this.model = this.ctx.model.Groupscore; } async opera({ data }) { const cList = data.filter(f => !(f.id || f._id)); const uList = data.filter(f => f.id || f._id); for (const i of cList) { await this.model.create(i); } for (const i of uList) { await this.model.findByIdAndUpdate(i.id || i._id, i); } // TODO计算优秀学生 } } module.exports = GroupscoreService;