Prechádzať zdrojové kódy

增加查询学生的班级名称

liuyu 4 rokov pred
rodič
commit
04e43210ad
1 zmenil súbory, kde vykonal 7 pridanie a 0 odobranie
  1. 7 0
      app/service/student.js

+ 7 - 0
app/service/student.js

@@ -13,6 +13,7 @@ class StudentService extends CrudService {
     this.model = this.ctx.model.Student;
     this.umodel = this.ctx.model.User;
     this.tmodel = this.ctx.model.Trainplan;
+    this.clamodel = this.ctx.model.Class;
   }
 
   // 查询
@@ -31,6 +32,12 @@ class StudentService extends CrudService {
           newdata.batchname = _batch.batch;
         }
       }
+      if (elm.classid) {
+        const classs = await this.clamodel.findById(elm.classid);
+        if (classs) {
+          newdata.classname = classs.name;
+        }
+      }
       data.push(newdata);
     }
     const result = { total, data };