zs 1 年間 前
コミット
c330021795
2 ファイル変更30 行追加0 行削除
  1. 12 0
      src/controller/course.controller.ts
  2. 18 0
      src/service/course.service.ts

+ 12 - 0
src/controller/course.controller.ts

@@ -53,6 +53,18 @@ export class CourseController extends BaseController {
     return { data, total };
   }
 
+  @Get('/only')
+  async only(@Query() filter: any) {
+    const list = await this.service.specialQuery(filter);
+    const data = [];
+    for (const i of list.data) {
+      const newData = new QVO_course(i);
+      data.push(newData);
+    }
+    const total = list.total;
+    return { data, total };
+  }
+
   @Get('/ranking')
   @ApiQuery({ name: 'query' })
   async rank(@Query() filter: any) {

+ 18 - 0
src/service/course.service.ts

@@ -14,6 +14,24 @@ export class CourseService extends BaseService<modelType> {
   @InjectEntityModel(Application)
   AppModel: ReturnModelType<typeof Application>;
 
+  async specialQuery(filter) {
+    const { skip = 0, limit = 0, ...info } = filter;
+    let obj = {};
+    if (info.team_id) {
+      obj = {
+        ...info,
+        $or: [
+          { red_team_id: { $eq: info.team_id } },
+          { blue_team_id: { $eq: info.team_id } },
+        ],
+      };
+    }
+    delete info.team_id;
+    const data: any = await this.model.find(obj).skip(skip).limit(limit);
+    const total = await this.model.count(info);
+    return { data, total };
+  }
+
   // 排名
   async rankQuery(filter) {
     const { match_id } = filter;