lrf402788946 4 anni fa
parent
commit
e8e704ba42
1 ha cambiato i file con 7 aggiunte e 3 eliminazioni
  1. 7 3
      app/service/student.js

+ 7 - 3
app/service/student.js

@@ -236,7 +236,10 @@ class StudentService extends CrudService {
 
   // 根据学生id删除学生
   async deletestus(data) {
-    throw new BusinessError(ErrorCode.BUSINESS, '此功能暂不开放,待确定好会出现的以外情况后,再次开放');
+    throw new BusinessError(
+      ErrorCode.BUSINESS,
+      '此功能暂不开放,待确定好会出现的以外情况后,再次开放'
+    );
     // for (const id of data) {
     //   await this.model.deleteOne({ _id: ObjectId(id) });
     //   await this.umodel.deleteOne({ uid: id });
@@ -410,16 +413,17 @@ class StudentService extends CrudService {
   }
 
   // 导出学生 目前:拓展训练保险用
-  async exportStudent(data) {
+  async exportStudent({ insurance = true, ...data }) {
     let { data: studentList } = await this.query(data);
     studentList = JSON.parse(JSON.stringify(studentList));
     let ids = studentList.map(i => i.classid);
     ids = _.uniq(ids);
     const classList = [];
+    // 此处可以优化,将班级整理,查出来,循环中find
     for (const id of ids) {
       const cla = await this.ctx.service.class.fetch({ id });
       if (!cla) continue;
-      cla.date = moment(cla.startdate).add(1, 'd').format('YYYY-MM-DD');
+      if (insurance) { cla.date = moment(cla.startdate).add(1, 'd').format('YYYY-MM-DD'); }
       classList.push(cla);
     }
     studentList = studentList.map(i => {