123456789101112131415161718192021222324252627282930313233343536 |
- '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 SchtimeService extends CrudService {
- constructor(ctx) {
- super(ctx, 'schtime');
- this.model = this.ctx.model.Schtime;
- }
- async updateschtimes(data) {
- assert(data, '缺少信息项');
- for (const elm of data) {
- const schtime = await this.model.findById(elm.id);
- if (schtime) {
- schtime.schid = elm.schid;
- schtime.year = elm.year;
- schtime.planid = elm.planid;
- schtime.remark = elm.remark;
- schtime.daterange = elm.daterange;
- schtime.term.splice(0, schtime.term.length);
- schtime.term = elm.term;
- await schtime.save();
- }
- }
- }
- }
- module.exports = SchtimeService;
|