|
|
@@ -187,15 +187,15 @@ export class VideoMediaService {
|
|
|
videoTime: row.videoTime,
|
|
|
size: row.size?.toString?.() ?? '0',
|
|
|
coverImg: row.coverImg ?? '',
|
|
|
- categoryIds: row.categoryIds ?? [],
|
|
|
- tagIds: row.tagIds ?? [],
|
|
|
+ // categoryIds: row.categoryIds ?? [],
|
|
|
+ // tagIds: row.tagIds ?? [],
|
|
|
listStatus: row.listStatus ?? 0,
|
|
|
editedAt: Number(row.editedAt ?? 0),
|
|
|
updatedAt: row.updatedAt ?? null,
|
|
|
tags: row.tags ?? [],
|
|
|
- tagsFlat: row.tagsFlat ?? '',
|
|
|
+ // tagsFlat: row.tagsFlat ?? '',
|
|
|
secondTags: row.secondTags ?? [],
|
|
|
- sanitizedSecondTags: row.sanitizedSecondTags ?? [],
|
|
|
+ // sanitizedSecondTags: row.sanitizedSecondTags ?? [],
|
|
|
})),
|
|
|
};
|
|
|
}
|
|
|
@@ -314,15 +314,15 @@ export class VideoMediaService {
|
|
|
country: video.country,
|
|
|
status: video.status,
|
|
|
desc: video.desc ?? '',
|
|
|
- categoryIds: video.categoryIds ?? [],
|
|
|
- tagIds: video.tagIds ?? [],
|
|
|
+ // categoryIds: video.categoryIds ?? [],
|
|
|
+ // tagIds: video.tagIds ?? [],
|
|
|
listStatus: video.listStatus ?? 0,
|
|
|
editedAt: Number(video.editedAt ?? 0),
|
|
|
updatedAt: video.updatedAt ?? null,
|
|
|
categoryName: category?.name ?? null,
|
|
|
// Existing DTO: tags as {id, name}[]
|
|
|
tags: video.tags ?? [],
|
|
|
- tagsFlat: video.tagsFlat ?? '',
|
|
|
+ // tagsFlat: video.tagsFlat ?? '',
|
|
|
secondTags: video.secondTags ?? [],
|
|
|
};
|
|
|
}
|
|
|
@@ -332,7 +332,8 @@ export class VideoMediaService {
|
|
|
where: { id: dto.id },
|
|
|
select: {
|
|
|
id: true,
|
|
|
- oSecondTags: true,
|
|
|
+ secondTags: true,
|
|
|
+ tags: true,
|
|
|
},
|
|
|
});
|
|
|
|
|
|
@@ -340,18 +341,25 @@ export class VideoMediaService {
|
|
|
throw new NotFoundException('Video not found');
|
|
|
}
|
|
|
|
|
|
- const mgntTags = dto.tags; // DTO enforces non-empty string[]
|
|
|
- const original = video.oSecondTags ?? [];
|
|
|
+ // MGNT sends structured tags now
|
|
|
+ const mgntVTags = Array.from(
|
|
|
+ new Map(
|
|
|
+ dto.tags.map((t) => [t.tagId, { tagId: t.tagId, tagName: t.tagName }]),
|
|
|
+ ).values(),
|
|
|
+ );
|
|
|
+ const mgntTagNames = mgntVTags.map((t) => t.tagName);
|
|
|
|
|
|
- // combine original + mgnt tags, keep order, remove duplicates
|
|
|
- const mergedSecondTags = Array.from(new Set([...original, ...mgntTags]));
|
|
|
+ const original = video.tags ?? [];
|
|
|
+ const mergedSecondTags = Array.from(
|
|
|
+ new Set([...original, ...mgntTagNames]),
|
|
|
+ );
|
|
|
|
|
|
await this.prisma.videoMedia.update({
|
|
|
where: { id: dto.id },
|
|
|
data: {
|
|
|
- tags: mgntTags,
|
|
|
- secondTags: mergedSecondTags,
|
|
|
- editedAt: BigInt(Math.floor(Date.now() / 1000)), // epoch seconds (BigInt)
|
|
|
+ vTags: { set: mgntVTags },
|
|
|
+ tags: { set: mergedSecondTags },
|
|
|
+ editedAt: BigInt(Math.floor(Date.now() / 1000)),
|
|
|
updatedAt: new Date(),
|
|
|
},
|
|
|
});
|