Преглед изворни кода

增加班主任默认生成用户

liuyu пре 5 година
родитељ
комит
656b2ff528
1 измењених фајлова са 9 додато и 0 уклоњено
  1. 9 0
      app/service/headteacher.js

+ 9 - 0
app/service/headteacher.js

@@ -11,6 +11,15 @@ 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);
   }
 
 }