grand commit

This commit is contained in:
2025-02-07 08:34:42 +02:00
parent f594f001f6
commit c6c34f0453
53 changed files with 1283 additions and 625 deletions

View File

@@ -6,7 +6,7 @@ model Category {
storeId Int @map("store_id")
locales CategoryLocale[]
createdAt DateTime @default(now()) @map("created_at")
categoriesOnPruducts CategoriesOnProducts[]
categoriesOnProducts CategoriesOnProducts[]
@@map("categories")
}
@@ -36,5 +36,5 @@ model CategoriesOnProducts {
categoryId Int @map("category_id")
@@id([storeId, productId, categoryId])
@@map("categories_on_pruducts")
@@map("categories_on_products")
}

View File

@@ -25,7 +25,7 @@ model ProductLocale {
shortTitle String? @map("short_title")
headingTitle String? @map("heading_title")
description String? @db.MediumText
content String @db.MediumText
content String? @db.MediumText
instruction String? @db.MediumText
product Product @relation(fields: [productId], references: [id])
productId Int @map("product_id")
@@ -40,12 +40,13 @@ model ProductResource {
id Int @id @default(autoincrement())
type ResourceType
mimeType String? @map("mime_type")
isFeature Boolean? @default(false)
filesize Int? @db.UnsignedInt
width Int? @db.UnsignedSmallInt
height Int? @db.UnsignedSmallInt
quality Int? @db.UnsignedTinyInt
signature String? @db.Char(64)
uri String @db.Text
quality Float? @db.Float
signature String @db.Char(64)
uri String @db.VarChar(1024)
title String? @db.VarChar(255)
description String? @db.Text
meta Json? @db.Json
@@ -54,6 +55,7 @@ model ProductResource {
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3)
updatedAt DateTime? @default(dbgenerated("NULL DEFAULT NULL ON UPDATE current_timestamp(3)")) @map("updated_at") @db.Timestamp(3)
@@unique([productId, signature])
@@map("product_resources")
}
@@ -85,15 +87,16 @@ model ProductAttribute {
}
model ProductToStore {
id Int @id @default(autoincrement())
position Int @default(0)
published Boolean @default(false)
available Boolean @default(false)
price Decimal @default(0) @db.Decimal(7, 2)
pricePromotional Decimal @default(0) @map("price_promotional") @db.Decimal(7, 2)
productId Int @map("product_id")
storeId Int @map("store_id")
product Product @relation(fields: [productId], references: [id])
id Int @id @default(autoincrement())
position Int @default(0)
published Boolean @default(false)
available Boolean @default(false)
price Decimal @default(0) @db.Decimal(7, 2)
pricePromotional Decimal @default(0) @map("price_promotional") @db.Decimal(7, 2)
productId Int @map("product_id")
storeId Int @map("store_id")
product Product @relation(fields: [productId], references: [id])
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3)
@@unique([storeId, productId])
@@map("product_to_store")

View File

@@ -0,0 +1,20 @@
SELECT DISTINCT
p.id as productId,
pl.lang,
pl.slug,
pr.uri as image,
pr.width as imageWidth,
pr.height as imageHeight,
pts.price,
pts.price_promotional as pricePromotional,
pl.title,
pl.short_title as shortTitle,
pl.description
-- pl.content, pl.heading_title as headingTitle, pl.instruction
FROM products p
JOIN categories_on_products cop ON p.id = cop.product_id
JOIN product_locale pl ON pl.product_id = p.id
JOIN product_to_store pts ON pts.product_id = p.id AND pts.store_id = cop.store_id
LEFT JOIN product_resources pr ON p.id = pr.product_id AND pr.isFeature = TRUE
WHERE cop.store_id = 1 AND pl.lang = ?
ORDER BY p.id DESC;

View File

@@ -0,0 +1,26 @@
SELECT
p.id as productId,
pl.lang,
pl.slug,
pr.uri as image,
pr.width as imageWidth,
pr.height as imageHeight,
pts.price,
pts.price_promotional as pricePromotional,
cl.category_id as categoryId,
pl.title,
pl.short_title as shortTitle,
pl.description,
-- pl.content,
pl.heading_title as headingTitle,
-- pl.instruction,
cl.slug as categorySlug,
cl.title as categoryTitle
FROM products p
JOIN categories_on_products cop ON p.id = cop.product_id
JOIN product_locale pl ON pl.product_id = p.id
JOIN category_locales cl ON cl.category_id = cop.category_id
JOIN product_to_store pts ON pts.product_id = p.id AND pts.store_id = cop.store_id
LEFT JOIN product_resources pr ON p.id = pr.product_id AND pr.isFeature = TRUE
WHERE cop.store_id = 1 AND cl.slug = ?
ORDER BY pl.lang;

View File

@@ -0,0 +1,26 @@
SELECT DISTINCT
p.id as productId,
pl.lang,
pl.slug,
pr.uri as image,
pr.width as imageWidth,
pr.height as imageHeight,
pts.price,
pts.price_promotional as pricePromotional,
cl.category_id as categoryId,
pl.title,
pl.short_title as shortTitle,
pl.description,
pl.content,
pl.heading_title as headingTitle,
pl.instruction,
cl.slug as categorySlug,
cl.title as categoryTitle
FROM products p
JOIN categories_on_products cop ON p.id = cop.product_id
JOIN product_locale pl ON pl.product_id = p.id
JOIN category_locales cl ON cl.category_id = cop.category_id
JOIN product_to_store pts ON pts.product_id = p.id AND pts.store_id = cop.store_id
LEFT JOIN product_resources pr ON p.id = pr.product_id AND pr.isFeature = TRUE
WHERE cop.store_id = 1 AND p.id = ?
ORDER BY pl.lang