personalscore.js 788 B

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