lrf402788946 há 4 anos atrás
pai
commit
9a44aac4d6
1 ficheiros alterados com 12 adições e 0 exclusões
  1. 12 0
      app/service/school.js

+ 12 - 0
app/service/school.js

@@ -20,6 +20,18 @@ class SchoolService extends CrudService {
     this.schmodel = this.ctx.model.Schtime;
   }
 
+  async create(data) {
+    const { code, name } = data;
+    assert(code, '缺少学校代码');
+    assert(name, '缺少学校名称');
+    const res = await this.model.create(data);
+    if (res) {
+      const obj = { mobile: code, name, type: '2', uid: res._id, passwd: { secret: '12345678' } };
+      await this.umodel.create(obj);
+    }
+    return res;
+  }
+
   async stuimport(data) {
     const { filepath, termid, schid, type, batchid } = data;
     assert(filepath, 'filepath不能为空');