feat(frontend): integrate Prisma and reports API/pages chore(config): add data_sources.yaml; update analysis-config.json docs: add 2025-11-03 dev log; update user guide scripts: enhance dev.sh; add tushare_legacy_client deps: update backend and frontend dependencies
30 lines
775 B
TypeScript
30 lines
775 B
TypeScript
import { NextRequest } from 'next/server'
|
||
import { prisma } from '../../../../lib/prisma'
|
||
|
||
export async function GET(
|
||
req: NextRequest,
|
||
context: { params: Promise<{ id: string }> }
|
||
) {
|
||
// 优先从动态路由 params(Promise)获取,其次从 URL 最后一段兜底
|
||
let id: string | undefined
|
||
try {
|
||
const { id: idFromParams } = await context.params
|
||
id = idFromParams
|
||
} catch {
|
||
// ignore
|
||
}
|
||
if (!id) {
|
||
id = new URL(req.url).pathname.split('/').pop() || undefined
|
||
}
|
||
|
||
if (!id) {
|
||
return Response.json({ error: 'missing id' }, { status: 400 })
|
||
}
|
||
|
||
const report = await prisma.report.findUnique({ where: { id } })
|
||
if (!report) {
|
||
return Response.json({ error: 'not found' }, { status: 404 })
|
||
}
|
||
return Response.json(report)
|
||
}
|