import { prisma } from "@/lib/prisma";
import { ok, ERR } from "@/lib/api-response";

interface RouteCtx {
  params: Promise<{ id: string }>;
}

/**
 * GET /api/artists/:id
 * 返回单个艺人详情（含表演图片列表）。
 */
export async function GET(_req: Request, { params }: RouteCtx) {
  try {
    const { id } = await params;
    const artist = await prisma.artist.findUnique({
      where: { id },
      include: {
        images: { orderBy: { sortOrder: "asc" } },
      },
    });
    if (!artist) return ERR.NOT_FOUND("艺人不存在");
    return ok({ artist });
  } catch (e) {
    console.error("[GET /api/artists/:id]", e);
    return ERR.INTERNAL();
  }
}
