This commit is contained in:
Your Name committed 2026-10-02 09:05:58 +07:00
1 parent f258e3e176
commit 3631f59bba
7 files changed
+524 -57

No files matched your search

@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Product" ADD COLUMN "titleGraphicUrl" TEXT;
-- AlterTable
ALTER TABLE "ProductVariant" ADD COLUMN "imageUrl" TEXT;
+2
View File
@@ -81,6 +81,7 @@ model Product {
categoryId Int
category Category @relation(fields: [categoryId], references: [id])
name String?
titleGraphicUrl String?
description String?
details String?
brandId Int
@@ -134,6 +135,7 @@ model ProductVariant {
option1 String @default("") // Maps to Product.options[0]
option2 String @default("") // Maps to Product.options[1]
option3 String @default("") // Maps to Product.options[2]
imageUrl String?
productId Int
product Product @relation(fields: [productId], references: [id])
+5
View File
@@ -118,6 +118,7 @@ async function createSingleProductTx(tx: any, payload: any, validateVariants: an
categoryId,
brandId,
name: pName,
titleGraphicUrl: payload.titleGraphicUrl || null,
description: pDesc,
details: pDetails,
options,
@@ -149,6 +150,7 @@ async function createSingleProductTx(tx: any, payload: any, validateVariants: an
option2: v.option2 || "",
option3: v.option3 || "",
price: v.price != null ? Number(v.price) : 0,
imageUrl: v.imageUrl || null,
}
});
}
@@ -676,6 +678,7 @@ export const productsRoute = new Elysia({ prefix: "/products" })
updateData.categoryId = categoryId;
}
if (body.options !== undefined) updateData.options = body.options;
if (body.titleGraphicUrl !== undefined) updateData.titleGraphicUrl = body.titleGraphicUrl || null;
const prod = await tx.product.update({
where: { id },
@@ -711,6 +714,7 @@ export const productsRoute = new Elysia({ prefix: "/products" })
option2: v.option2 || "",
option3: v.option3 || "",
price: v.price || 0,
imageUrl: v.imageUrl !== undefined ? (v.imageUrl || null) : undefined,
bomItems: v.bomItems ? {
deleteMany: {},
create: v.bomItems.map((b: any) => ({
@@ -732,6 +736,7 @@ export const productsRoute = new Elysia({ prefix: "/products" })
option2: v.option2 || "",
option3: v.option3 || "",
price: v.price || 0,
imageUrl: v.imageUrl || null,
bomItems: v.bomItems && v.bomItems.length > 0 ? {
create: v.bomItems.map((b: any) => ({
rawMaterialId: b.rawMaterialId,