12345678910111213141516171819202122232425262728 |
- '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 PersonalscoreService extends CrudService {
- constructor(ctx) {
- super(ctx, 'personalscore');
- this.model = this.ctx.model.Personalscore;
- }
- 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 = PersonalscoreService;
|