Selaa lähdekoodia

feat: 录播图列表接口

IlhamTahir 1 vuosi sitten
vanhempi
commit
efab650808

+ 9 - 0
src/article/controller/carousal.controller.ts

@@ -61,6 +61,15 @@ export class CarousalController {
     );
   }
 
+  @Get('active-list')
+  @ApiBearerAuth()
+  @ApiOkResponse({
+    type: Array<CarousalVo>,
+  })
+  async activeList() {
+    return CarousalMapper.toVos(await this.carousalService.activeList());
+  }
+
   @Get(':id')
   @ApiBearerAuth()
   @ApiOkResponse({

+ 3 - 1
src/article/dto/create-carousal.request.ts

@@ -1,5 +1,5 @@
 import { ApiProperty } from '@nestjs/swagger';
-import { IsNotEmpty } from 'class-validator';
+import { IsNotEmpty, IsOptional } from 'class-validator';
 import { CarousalTargetType } from '../enum/carousal-target-type.enum';
 
 export class CreateCarousalRequest {
@@ -16,8 +16,10 @@ export class CreateCarousalRequest {
   @ApiProperty({
     example: 'https://example.cc',
   })
+  @IsOptional()
   targetUrl: string;
 
   @ApiProperty()
+  @IsOptional()
   targetId: string;
 }

+ 9 - 0
src/article/service/carousal.service.ts

@@ -65,4 +65,13 @@ export class CarousalService {
     const carousal = await this.get(id);
     return this.carousalRepository.remove(carousal);
   }
+
+  async activeList() {
+    return this.carousalRepository.find({
+      where: {
+        status: CarousalStatus.ACTIVE,
+      },
+      order: { createdTime: 'DESC' },
+    });
+  }
 }