reloaded 4 éve
szülő
commit
33670a3ba8
1 módosított fájl, 21 hozzáadás és 2 törlés
  1. 21 2
      app/service/class.js

+ 21 - 2
app/service/class.js

@@ -18,6 +18,7 @@ class ClassService extends CrudService {
     this.gmodel = this.ctx.model.Group;
     this.heamodel = this.ctx.model.Headteacher;
     this.teamodel = this.ctx.model.Teacher;
+    this.locamodel = this.ctx.model.Location;
   }
 
   async divide(data) {
@@ -153,8 +154,6 @@ class ClassService extends CrudService {
 
   async fetch({ id }) {
     const classInfo = _.cloneDeep(JSON.parse(JSON.stringify(await this.model.findById(id))));
-    console.log(classInfo);
-
     const trainplan = await this.tmodel.findById(classInfo.planid);
     if (trainplan) {
       const term = _.filter(trainplan.termnum, item => item.id === classInfo.termid);
@@ -168,6 +167,26 @@ class ClassService extends CrudService {
         }
       }
     }
+    if (classInfo.yclocationid) {
+      classInfo.yclocation = (await this.locamodel.findById(classInfo.yclocationid)).name;
+    }
+    if (classInfo.kzjhlocationid) {
+      classInfo.kzjhlocation = (await this.locamodel.findById(classInfo.kzjhlocationid)).name;
+    }
+    if (classInfo.kbyslocationid) {
+      classInfo.kbyslocation = (await this.locamodel.findById(classInfo.kbyslocationid)).name;
+    }
+    if (classInfo.jslocationid) {
+      classInfo.jslocation = (await this.locamodel.findById(classInfo.jslocationid)).name;
+    }
+    if (classInfo.headteacherid) {
+      classInfo.headteacher = (await this.heamodel.findById(classInfo.headteacherid)).name;
+    }
+    if (classInfo.lyteacherid) {
+      let res = await this.teamodel.findById(classInfo.lyteacherid);
+      if (!res) res = await this.heamodel.findById(classInfo.lyteacherid);
+      if (res)classInfo.lyteacher = res.name;
+    }
     return classInfo;
   }