'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 HeadteacherService extends CrudService { constructor(ctx) { super(ctx, 'headteacher'); this.model = this.ctx.model.Headteacher; this.umodel = this.ctx.model.User; } async create(data) { const { name, phone } = data; const res = await this.model.create(data); const newdata = { name, mobile: phone, type: '1', uid: res.id }; newdata.passwd = { secret: '12345678' }; await this.umodel.create(newdata); } } module.exports = HeadteacherService;