|
|
@@ -39,6 +39,25 @@ export class VideoMediaService {
|
|
|
private readonly mediaStorageStrategy: StorageStrategy,
|
|
|
) {}
|
|
|
|
|
|
+ private normalizeMongoIdToString(id: unknown): string {
|
|
|
+ if (typeof id === 'string') return id;
|
|
|
+
|
|
|
+ if (id && typeof id === 'object') {
|
|
|
+ const anyId = id as any;
|
|
|
+
|
|
|
+ // Extended JSON: { $oid: "..." }
|
|
|
+ if (typeof anyId.$oid === 'string') return anyId.$oid;
|
|
|
+
|
|
|
+ // BSON ObjectId instance (common)
|
|
|
+ if (typeof anyId.toHexString === 'function') return anyId.toHexString();
|
|
|
+
|
|
|
+ // Fallback: best-effort string conversion
|
|
|
+ if (typeof anyId.toString === 'function') return anyId.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ return String(id);
|
|
|
+ }
|
|
|
+
|
|
|
// helper to generate next vid
|
|
|
private async generateNextVid(): Promise<number> {
|
|
|
const last = await this.prisma.videoMedia.findFirst({
|
|
|
@@ -178,7 +197,7 @@ export class VideoMediaService {
|
|
|
page,
|
|
|
pageSize,
|
|
|
items: rows.map((row) => ({
|
|
|
- id: row.id,
|
|
|
+ id: this.normalizeMongoIdToString(row.id),
|
|
|
vid: row.vid ?? null,
|
|
|
title: row.title,
|
|
|
filename: row.filename,
|
|
|
@@ -300,7 +319,7 @@ export class VideoMediaService {
|
|
|
]);
|
|
|
|
|
|
return {
|
|
|
- id: video.id,
|
|
|
+ id: this.normalizeMongoIdToString(video.id),
|
|
|
title: video.title,
|
|
|
filename: video.filename,
|
|
|
preFileName: video.preFileName,
|