zs 1 year ago
parent
commit
8e4d8b7f3d
1 changed files with 11 additions and 3 deletions
  1. 11 3
      src/service/application.service.ts

+ 11 - 3
src/service/application.service.ts

@@ -70,7 +70,7 @@ export class ApplicationService extends BaseService<modelType> {
       }
     }
   }
-
+  // 特殊处理查询
   async specialQuery(filter) {
     const { skip = 0, limit = 0, ...info } = filter;
     if (info.user) {
@@ -94,18 +94,26 @@ export class ApplicationService extends BaseService<modelType> {
       return { list, total };
     }
   }
+  // 查询参赛团队
   async teamQuery(filter) {
     const { skip = 0, limit = 0, ...info } = filter;
     const data: any = await this.model.find(info);
     const team = data.map(i => {
       return i.team_id;
     });
-    const list = [];
+    const res = [];
     for (const val of team) {
       const data = await this.TeamModel.findById(val);
-      list.push(data);
+      res.push(data);
     }
+    const list = this.pagination(skip, limit, res);
     const total = list.length;
     return { list, total };
   }
+  pagination(pageNo, pageSize, array) {
+    const offset = pageNo * pageSize;
+    return offset + pageSize >= array.length
+      ? array.slice(offset, array.length)
+      : array.slice(offset, offset + pageSize);
+  }
 }