import { prisma } from "@/lib/prisma"; import { NextResponse } from "next/server"; export async function GET(_req: Request, { params }: { params: { id: string } }) { try { const userId = parseInt(params.id); if (isNaN(userId)) { return NextResponse.json({ error: "无效的用户ID" }, { status: 400 }); } const posts = await prisma.forumPost.findMany({ where: { userId, isHidden: false }, include: { topic: { select: { id: true, title: true } }, }, orderBy: { createdAt: "desc" }, take: 30, }); return NextResponse.json({ posts }); } catch (error: unknown) { const err = error as { message?: string }; return NextResponse.json({ error: err.message || "获取回复失败" }, { status: 500 }); } }