'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 StudentService extends CrudService { constructor(ctx) { super(ctx, 'student'); this.model = this.ctx.model.User.Student; this.rssModel = this.ctx.model.Relation.RelationStudentSchool; } async afterCreate(body, data) { if (!_.get(body, 'school_id')) return data; const { _id: student_id } = data; const obj = { school_id: _.get(body, 'school_id'), student_id }; await this.rssModel.create(obj); return data; } } module.exports = StudentService;