|
|
@@ -316,6 +316,36 @@ export class VideoMediaService {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ // create an async function to delete a video media by id and return the deleted id also update Redis cache
|
|
|
+ async delete(id: string) {
|
|
|
+ const video = await this.prisma.videoMedia.findUnique({
|
|
|
+ where: { id },
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!video) {
|
|
|
+ throw new NotFoundException('Video not found');
|
|
|
+ }
|
|
|
+
|
|
|
+ await this.prisma.videoMedia.delete({
|
|
|
+ where: { id },
|
|
|
+ });
|
|
|
+
|
|
|
+ // Refresh category video lists cache if video has a category
|
|
|
+ if (video.categoryIds && video.categoryIds.length > 0) {
|
|
|
+ for (const categoryId of video.categoryIds) {
|
|
|
+ await this.cacheSyncService.scheduleAction({
|
|
|
+ entityType: CacheEntityType.VIDEO_LIST,
|
|
|
+ operation: 'REFRESH',
|
|
|
+ payload: { categoryId },
|
|
|
+ } as any);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ id,
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Upload and update VideoMedia cover image.
|
|
|
*/
|