groupscore.js 775 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. const assert = require('assert');
  3. const _ = require('lodash');
  4. const { ObjectId } = require('mongoose').Types;
  5. const { CrudService } = require('naf-framework-mongoose/lib/service');
  6. const { BusinessError, ErrorCode } = require('naf-core').Error;
  7. class GroupscoreService extends CrudService {
  8. constructor(ctx) {
  9. super(ctx, 'groupscore');
  10. this.model = this.ctx.model.Groupscore;
  11. }
  12. async opera({ data }) {
  13. const cList = data.filter(f => !(f.id || f._id));
  14. const uList = data.filter(f => f.id || f._id);
  15. for (const i of cList) {
  16. await this.model.create(i);
  17. }
  18. for (const i of uList) {
  19. await this.model.findByIdAndUpdate(i.id || i._id, i);
  20. }
  21. // TODO计算优秀学生
  22. }
  23. }
  24. module.exports = GroupscoreService;