Просмотр исходного кода

修改额外创建学校的安排数据

lrf 1 год назад
Родитель
Сommit
a9a636004b
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      app/service/trainplan.js

+ 3 - 1
app/service/trainplan.js

@@ -40,7 +40,9 @@ class TrainplanService extends CrudService {
     for (const sch of schoolList) {
       const { code } = sch;
       const obj = { schid: code, year, planid };
-      const schtimeres = await this.schmodel.create(obj);
+      let schtimeres;
+      schtimeres = await this.schmodel.findOne(obj);
+      if (!schtimeres)schtimeres = await this.schmodel.create(obj);
       if (schtimeres) schtimeArr.push(schtimeres);
     }
     if (!schtimeArr.every(e => e)) { throw new BusinessError(ErrorCode.DATA_INVALID, '学校计划生成失败'); } else return res;