Prechádzať zdrojové kódy

feat(video-media): add optional tag filter to VideoMediaListQueryDto and service

Dave 1 mesiac pred
rodič
commit
fba07e58b6

+ 1 - 4
apps/box-mgnt-api/src/mgnt-backend/feature/uploader/uploader.controller.ts

@@ -52,9 +52,6 @@ export class UploaderController {
       fileType,
     );
 
-    return {
-      keyPath: result.keyPath,
-      imageStorage: result.imageStorage,
-    };
+    return result;
   }
 }

+ 12 - 0
apps/box-mgnt-api/src/mgnt-backend/feature/video-media/video-media.dto.ts

@@ -30,6 +30,18 @@ export class VideoMediaListQueryDto extends PageListDto {
   @MaxLength(100)
   keyword?: string;
 
+  // search tags
+  @ApiPropertyOptional({
+    type: String,
+    maxLength: 100,
+    description: '搜索标签关键词,用于匹配视频标签',
+    example: '演示',
+  })
+  @IsOptional()
+  @IsString()
+  @MaxLength(100)
+  tag?: string;
+
   /**
    * 上/下架状态过滤
    * 0 = 下架, 1 = 上架

+ 9 - 0
apps/box-mgnt-api/src/mgnt-backend/feature/video-media/video-media.service.ts

@@ -209,6 +209,15 @@ export class VideoMediaService {
       where.listStatus = query.listStatus;
     }
 
+    // filter by tag, by videoMedia.secondTags[]
+    if (typeof query.tag === 'string' && query.tag.trim() !== '') {
+      where.secondTags = {
+        $elemMatch: {
+          $eq: query.tag.trim(),
+        },
+      };
+    }
+
     if (
       typeof query.updatedFrom === 'number' ||
       typeof query.updatedTo === 'number'