123456789101112131415161718192021222324252627 |
- 'use strict';
- const { CrudService } = require('naf-framework-mongoose-free/lib/service');
- const { BusinessError, ErrorCode } = require('naf-core').Error;
- const _ = require('lodash');
- const assert = require('assert');
- //
- class TryLessonApplyService extends CrudService {
- constructor(ctx) {
- super(ctx, 'trylessonapply');
- this.model = this.ctx.model.Apply.TryLessonApply;
- this.lessonStudentService = this.ctx.service.business.lessonStudent;
- }
- // 处理审核成功的情况
- async afterUpdate(filter, body, data) {
- const { status } = data;
- // 审核不通过, 不处理
- if (status !== '1') return data;
- // 通过,则需要在 lessonStudent中添加数据
- const obj = _.pick(data, [ 'school_id', 'lesson_id', 'student_id' ]);
- obj.is_try = '1';
- await this.lessonStudentService.create(obj);
- return data;
- }
- }
- module.exports = TryLessonApplyService;
|