liuyu 4 anni fa
parent
commit
9245f727d2
1 ha cambiato i file con 7 aggiunte e 3 eliminazioni
  1. 7 3
      app/service/school.js

+ 7 - 3
app/service/school.js

@@ -47,18 +47,22 @@ class SchoolService extends CrudService {
     if (datacheck.errorcode === '1') {
       return datacheck;
     }
-    const school_ = await this.smodel.findOne({ code: schid });
+    const school_ = await this.model.findOne({ code: schid });
+    let schname = '';
+    if (school_) {
+      schname = school_.name;
+    }
     const trem_ = await plan.termnum.id(termid);
     if (!trem_) {
       throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '期信息不存在');
     }
     const nowtime = moment().locale('zh-cn').format('YYYY-MM-DD HH:mm:ss');
     if (studatas.length > Number(num_)) {
-      const jobdata = { code: schid, name: school_.name, planid: plan.id, termid, term: trem_.term, filepath, studs: JSON.stringify(studatas), plannum: num_, schnum: studatas.length, isstore: '0', createtime: nowtime };
+      const jobdata = { code: schid, name: schname, planid: plan.id, termid, term: trem_.term, filepath, studs: JSON.stringify(studatas), plannum: num_, schnum: studatas.length, isstore: '0', createtime: nowtime };
       await this.jmodel.create(jobdata);
       throw new BusinessError(ErrorCode.SERVICE_FAULT, '学校上传人数超过预期人数');
     } else if (studatas.length < Number(num_)) {
-      const jobdata = { code: schid, name: school_.name, planid: plan.id, termid, term: trem_.term, filepath, studs: JSON.stringify(studatas), plannum: num_, schnum: studatas.length, isstore: '0', createtime: nowtime };
+      const jobdata = { code: schid, name: schname, planid: plan.id, termid, term: trem_.term, filepath, studs: JSON.stringify(studatas), plannum: num_, schnum: studatas.length, isstore: '0', createtime: nowtime };
       await this.jmodel.create(jobdata);
       throw new BusinessError(ErrorCode.SERVICE_FAULT, '学校上传人数少于预期人数');
     }