refactor(db): migrate app pages and APIs from Prisma facade to Drizzle (5)
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
9aa4f331bf
commit
30b54e99e7
40 files changed
+1183
-784
No files matched your search
@@ -1,8 +1,9 @@
|
||||
// Public REST: a single rare furni trade value by id (website_rare_values),
|
||||
// together with its parent category. AtomCMS JSON API parity. Returns { error }
|
||||
// (404) when the id is unknown.
|
||||
import { eq } from "drizzle-orm";
|
||||
import { apiJson } from "@/lib/api";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { db, WebsiteRareValueCategories, WebsiteRareValues } from "@/lib/db";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -25,21 +26,22 @@ export async function GET(
|
||||
}
|
||||
|
||||
try {
|
||||
const value = await prisma.websiteRareValues.findUnique({
|
||||
where: { id: valueId },
|
||||
select: {
|
||||
id: true,
|
||||
categoryId: true,
|
||||
itemId: true,
|
||||
name: true,
|
||||
creditValue: true,
|
||||
currencyValue: true,
|
||||
currencyType: true,
|
||||
furnitureIcon: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
},
|
||||
});
|
||||
const [value] = await db
|
||||
.select({
|
||||
id: WebsiteRareValues.id,
|
||||
categoryId: WebsiteRareValues.categoryId,
|
||||
itemId: WebsiteRareValues.itemId,
|
||||
name: WebsiteRareValues.name,
|
||||
creditValue: WebsiteRareValues.creditValue,
|
||||
currencyValue: WebsiteRareValues.currencyValue,
|
||||
currencyType: WebsiteRareValues.currencyType,
|
||||
furnitureIcon: WebsiteRareValues.furnitureIcon,
|
||||
createdAt: WebsiteRareValues.createdAt,
|
||||
updatedAt: WebsiteRareValues.updatedAt,
|
||||
})
|
||||
.from(WebsiteRareValues)
|
||||
.where(eq(WebsiteRareValues.id, valueId))
|
||||
.limit(1);
|
||||
|
||||
if (!value) {
|
||||
return apiJson({ error: "Rare value not found" }, { status: 404 });
|
||||
@@ -54,10 +56,17 @@ export async function GET(
|
||||
priority: number;
|
||||
} | null = null;
|
||||
try {
|
||||
category = await prisma.websiteRareValueCategories.findUnique({
|
||||
where: { id: value.categoryId },
|
||||
select: { id: true, name: true, badge: true, priority: true },
|
||||
});
|
||||
const [row] = await db
|
||||
.select({
|
||||
id: WebsiteRareValueCategories.id,
|
||||
name: WebsiteRareValueCategories.name,
|
||||
badge: WebsiteRareValueCategories.badge,
|
||||
priority: WebsiteRareValueCategories.priority,
|
||||
})
|
||||
.from(WebsiteRareValueCategories)
|
||||
.where(eq(WebsiteRareValueCategories.id, value.categoryId))
|
||||
.limit(1);
|
||||
category = row ?? null;
|
||||
} catch {
|
||||
category = null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user