fix model get req in new simulator
This commit is contained in:
parent
ff67d48bcc
commit
3b0cc31f27
@ -11,29 +11,16 @@ export async function GET() {
|
|||||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户信息和订阅套餐
|
// 获取所有激活的模型(不再与套餐绑定)
|
||||||
const userWithPlan = await prisma.user.findUnique({
|
const allModels = await prisma.model.findMany({
|
||||||
where: { id: user.id },
|
where: { isActive: true },
|
||||||
include: {
|
orderBy: [
|
||||||
subscriptionPlan: {
|
{ provider: "asc" },
|
||||||
include: {
|
{ name: "asc" }
|
||||||
models: {
|
]
|
||||||
where: { isActive: true },
|
|
||||||
orderBy: [
|
|
||||||
{ provider: "asc" },
|
|
||||||
{ name: "asc" }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!userWithPlan) {
|
const models = allModels.map(model => ({
|
||||||
return NextResponse.json({ error: "User not found" }, { status: 404 });
|
|
||||||
}
|
|
||||||
|
|
||||||
const models = userWithPlan.subscriptionPlan.models.map(model => ({
|
|
||||||
id: model.id,
|
id: model.id,
|
||||||
modelId: model.modelId,
|
modelId: model.modelId,
|
||||||
name: model.name,
|
name: model.name,
|
||||||
|
Loading…
Reference in New Issue
Block a user