Переглянути джерело

feat(video-media): add editedAt filtering by timestamp range in VideoMediaListQueryDto

Dave 2 місяців тому
батько
коміт
c3bd1e1bd9

+ 44 - 19
apps/box-mgnt-api/src/mgnt-backend/feature/video-media/video-media.dto.ts

@@ -69,6 +69,34 @@ export class VideoMediaListQueryDto extends PageListDto {
   @IsInt()
   @IsIn([0, 1])
   listStatus?: number;
+
+  /**
+   * 搜索 更新时间 范围 - 开始时间(EPOCH 秒)
+   */
+  @ApiPropertyOptional({
+    type: Number,
+    description: '更新时间范围过滤的开始时间(EPOCH 毫秒)',
+    example: 1700000000,
+  })
+  @IsOptional()
+  @Type(() => Number)
+  @IsInt()
+  @Min(0)
+  editedFrom?: number;
+
+  /**
+   * 搜索 更新时间 范围 - 结束时间(EPOCH 秒)
+   */
+  @ApiPropertyOptional({
+    type: Number,
+    description: '更新时间范围过滤的结束时间(EPOCH 毫秒)',
+    example: 1705000000,
+  })
+  @IsOptional()
+  @Type(() => Number)
+  @IsInt()
+  @Min(0)
+  editedTo?: number;
 }
 
 export class UpdateVideoMediaManageDto {
@@ -183,13 +211,12 @@ export class UpdateVideoMediaCoverResponseDto {
    * 新 editedAt 值
    */
   @ApiProperty({
-    type: String,
-    format: 'date-time',
-    description: '更新后的编辑时间戳(ISO 8601 格式)',
-    example: '2025-12-04T10:30:00.000Z',
+    type: Number,
+    description: '编辑时间戳(EPOCH 毫秒)',
+    example: 1733304600000,
   })
-  @IsString()
-  editedAt!: string;
+  @IsInt()
+  editedAt!: number;
 }
 
 export class VideoMediaListItemDto {
@@ -291,16 +318,15 @@ export class VideoMediaListItemDto {
   listStatus!: number;
 
   /**
-   * 本地编辑时间(BigInt epoch)— 字符串返回
+   * 编辑时间戳(EPOCH 毫秒)
    */
   @ApiProperty({
-    type: String,
-    format: 'date-time',
-    description: '编辑时间戳(ISO 8601 格式)',
-    example: '2025-12-04T10:30:00.000Z',
+    type: Number,
+    description: '编辑时间戳(EPOCH 毫秒)',
+    example: 1733304600000,
   })
-  @IsString()
-  editedAt!: string;
+  @IsInt()
+  editedAt!: number;
 }
 
 export class VideoMediaDetailDto {
@@ -438,13 +464,12 @@ export class VideoMediaDetailDto {
   listStatus!: number;
 
   @ApiProperty({
-    type: String,
-    format: 'date-time',
-    description: '编辑时间戳(ISO 8601 格式)',
-    example: '2025-12-04T10:30:00.000Z',
+    type: Number,
+    description: '编辑时间戳(EPOCH 毫秒)',
+    example: 1733304600000,
   })
-  @IsString()
-  editedAt!: string;
+  @IsInt()
+  editedAt!: number;
 
   // --- Optional denormalized information for UI convenience ---
 

+ 17 - 3
apps/box-mgnt-api/src/mgnt-backend/feature/video-media/video-media.service.ts

@@ -43,6 +43,20 @@ export class VideoMediaService {
       where.listStatus = query.listStatus;
     }
 
+    // filter by editedFrom and editedTo
+    if (
+      typeof query.editedFrom === 'number' ||
+      typeof query.editedTo === 'number'
+    ) {
+      where.editedAt = {};
+      if (typeof query.editedFrom === 'number') {
+        where.editedAt.gte = BigInt(query.editedFrom);
+      }
+      if (typeof query.editedTo === 'number') {
+        where.editedAt.lte = BigInt(query.editedTo);
+      }
+    }
+
     const [total, rows] = await Promise.all([
       this.prisma.videoMedia.count({ where }),
       this.prisma.videoMedia.findMany({
@@ -67,7 +81,7 @@ export class VideoMediaService {
         categoryId: row.categoryId ?? null,
         tagIds: row.tagIds ?? [],
         listStatus: row.listStatus ?? 0,
-        editedAt: row.editedAt?.toString?.() ?? '0',
+        editedAt: row.editedAt ?? 0,
         // NOTE: We keep list DTO backward compatible.
         // If you later want to show tag names in list, we can add e.g. `tagsFlat` or `tagNames` here.
       })),
@@ -113,10 +127,10 @@ export class VideoMediaService {
       categoryId: video.categoryId ?? null,
       tagIds: video.tagIds ?? [],
       listStatus: video.listStatus ?? 0,
-      editedAt: video.editedAt?.toString?.() ?? '0',
+      editedAt: Number(video.editedAt ?? 0),
       categoryName: category?.name ?? null,
       // Existing DTO: tags as {id, name}[]
-      tags: tags.map((t) => ({ id: t.id, name: t.name })),
+      tags: tags.map((t: any) => ({ id: t.id, name: t.name })),
     };
   }