45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { auth } from "@/auth";
|
|
import { db } from "@/lib/db";
|
|
|
|
// GET /api/storyboard/shots?projectId=xxx
|
|
export async function GET(req: NextRequest) {
|
|
const session = await auth();
|
|
if (!session?.user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
if (!["ADMIN", "PRODUCER", "SUPERVISOR"].includes(session.user.role)) {
|
|
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
|
}
|
|
|
|
const projectId = req.nextUrl.searchParams.get("projectId");
|
|
if (!projectId) return NextResponse.json({ error: "projectId required" }, { status: 400 });
|
|
|
|
const shots = await db.shot.findMany({
|
|
where: { projectId },
|
|
select: {
|
|
id: true,
|
|
shotCode: true,
|
|
scene: true,
|
|
episode: true,
|
|
shotNumber: true,
|
|
sequence: true,
|
|
description: true,
|
|
notes: true,
|
|
status: true,
|
|
thumbnailUrl: true,
|
|
frameStart: true,
|
|
frameEnd: true,
|
|
fps: true,
|
|
isKeyShot: true,
|
|
shotVersion: true,
|
|
shotGroup: { select: { id: true, name: true } },
|
|
},
|
|
orderBy: [
|
|
{ episode: "asc" },
|
|
{ scene: "asc" },
|
|
{ shotNumber: "asc" },
|
|
],
|
|
});
|
|
|
|
return NextResponse.json({ shots });
|
|
}
|