zs hace 1 año
padre
commit
f5b8d527a6
Se han modificado 2 ficheros con 36 adiciones y 0 borrados
  1. 6 0
      src/controller/core/video.controller.ts
  2. 30 0
      src/service/core/video.service.ts

+ 6 - 0
src/controller/core/video.controller.ts

@@ -32,6 +32,12 @@ export class VideoController extends BaseController {
     return { data, total };
   }
 
+  @Get('/list')
+  async list() {
+    const data = await this.service.list();
+    return data;
+  }
+
   @Get('/:id')
   @ApiResponse({ type: FVO_video })
   async fetch(@Param('id') id: string) {

+ 30 - 0
src/service/core/video.service.ts

@@ -13,4 +13,34 @@ export class VideoService extends BaseService<modelType> {
     const { number, _id } = data;
     await this.model.updateOne({ _id }, { number: number + 1 });
   }
+  // 首页查询
+  async list() {
+    const one = { type: '0', is_use: '0', status: '1' };
+    const two = { type: '1', is_use: '0', status: '1' };
+    const thr = { type: '2', is_use: '0', status: '1' };
+    const four = { type: '3', is_use: '0', status: '1' };
+    const five = { type: '4', is_use: '0', status: '1' };
+    let data;
+    data = await this.model.find(one).skip(0).limit(7).lean();
+    const oneInfo = data[0] || {};
+    const oneList = data.slice(1, 7) || [];
+    const oneTotal = await this.model.count(one);
+    data = await this.model.find(two).skip(0).limit(7).lean();
+    const twoInfo = data[0]|| {};
+    const twoList = data.slice(1, 7)|| [];
+    const twoTotal = await this.model.count(two);
+    data = await this.model.find(thr).skip(0).limit(7).lean();
+    const thrInfo = data[0]|| {};
+    const thrList = data.slice(1, 7)|| [];
+    const thrTotal = await this.model.count(thr);
+    data = await this.model.find(four).skip(0).limit(7).lean();
+    const fourInfo = data[0]|| {};
+    const fourList = data.slice(1, 7)|| [];
+    const fourTotal = await this.model.count(four);
+    data = await this.model.find(five).skip(0).limit(7).lean();
+    const fiveInfo = data[0]|| {};
+    const fiveList = data.slice(1, 7)|| [];
+    const fiveTotal = await this.model.count(five);
+    return { oneInfo, oneList, oneTotal, twoInfo, twoList, twoTotal, thrInfo, thrList, thrTotal, fourInfo, fourList, fourTotal, fiveInfo, fiveList, fiveTotal };
+  }
 }