feat: add product variant management functionality
- Implemented CreateProductVariantDto and UpdateProductVariantDto for product variant data transfer. - Developed ProductVariantsController to handle CRUD operations for product variants. - Created ProductVariantsService to interact with the database using Prisma. - Added ProductVariantsModule to encapsulate the product variant feature. - Included response mapping for consistent API responses.
This commit is contained in:
+19
-25
@@ -35,26 +35,25 @@ model Role {
|
||||
@@map("Roles")
|
||||
}
|
||||
|
||||
model Product {
|
||||
model ProductVariant {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @db.VarChar(255)
|
||||
basePrice Decimal @db.Decimal(10, 2)
|
||||
salePrice Decimal @db.Decimal(10, 2)
|
||||
description String? @db.Text
|
||||
sku String? @unique(map: "products_sku_unique") @db.VarChar(100)
|
||||
barcode String? @unique(map: "products_barcode_unique") @db.VarChar(100)
|
||||
imageUrl String? @db.VarChar(255)
|
||||
attachmentId BigInt? @db.UnsignedBigInt
|
||||
unit String @db.VarChar(10)
|
||||
discount Decimal @default(0.00) @db.Decimal(10, 2)
|
||||
quantity Decimal @default(0.00) @db.Decimal(10, 2)
|
||||
alertQuantity Decimal @default(5.00) @db.Decimal(10, 2)
|
||||
unit String? @db.VarChar(10)
|
||||
quantity Decimal? @default(0.00) @db.Decimal(10, 2)
|
||||
alertQuantity Decimal? @default(5.00) @db.Decimal(10, 2)
|
||||
isActive Boolean @default(true)
|
||||
isFeatured Boolean @default(false)
|
||||
createdAt DateTime? @db.Timestamp(0)
|
||||
updatedAt DateTime? @db.Timestamp(0)
|
||||
deletedAt DateTime? @db.Timestamp(0)
|
||||
|
||||
productInfo ProductInfo @relation("Product_ProductInfo", fields: [productInfoId], references: [id], onUpdate: NoAction)
|
||||
productInfoId Int
|
||||
product Product @relation("Product_Variant", fields: [productId], references: [id], onUpdate: NoAction)
|
||||
productId Int
|
||||
// is_stock_managed Boolean @default(true)
|
||||
// created_by Int?
|
||||
// collection_product collection_product[]
|
||||
@@ -64,32 +63,29 @@ model Product {
|
||||
// purchase_items purchase_items[]
|
||||
// sale_items sale_items[]
|
||||
|
||||
// @@index([attachment_id], map: "products_attachment_id_foreign")
|
||||
@@map("Products")
|
||||
@@map("Product_Variants")
|
||||
}
|
||||
|
||||
model ProductInfo {
|
||||
model Product {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @db.VarChar(255)
|
||||
barcode String? @unique(map: "products_barcode_unique") @db.VarChar(100)
|
||||
sku String? @unique(map: "products_sku_unique") @db.VarChar(100)
|
||||
description String? @db.Text
|
||||
productType String? @default("simple") @db.VarChar(50)
|
||||
metaData Json?
|
||||
// productType String? @default("simple") @db.VarChar(50)
|
||||
createdAt DateTime @default(now()) @db.Timestamp(0)
|
||||
updatedAt DateTime @updatedAt @db.Timestamp(0)
|
||||
deletedAt DateTime? @db.Timestamp(0)
|
||||
|
||||
products Product[] @relation("Product_ProductInfo")
|
||||
variants ProductVariant[] @relation("Product_Variant")
|
||||
|
||||
brand ProductBrand? @relation("ProductInfo_Brand", fields: [brandId], references: [id], onUpdate: NoAction)
|
||||
brand ProductBrand? @relation("Product_Brand", fields: [brandId], references: [id], onUpdate: NoAction)
|
||||
brandId Int?
|
||||
|
||||
category ProductCategory? @relation("ProductInfo_Category", fields: [categoryId], references: [id], onUpdate: NoAction)
|
||||
category ProductCategory? @relation("Product_Category", fields: [categoryId], references: [id], onUpdate: NoAction)
|
||||
categoryId Int?
|
||||
|
||||
supplier Supplier @relation("ProductInfo_Supplier", fields: [supplierId], references: [id], onUpdate: NoAction)
|
||||
supplierId Int
|
||||
|
||||
@@map("Product_info")
|
||||
@@map("Products")
|
||||
}
|
||||
|
||||
model ProductBrand {
|
||||
@@ -101,7 +97,7 @@ model ProductBrand {
|
||||
updatedAt DateTime @updatedAt @db.Timestamp(0)
|
||||
deletedAt DateTime? @db.Timestamp(0)
|
||||
|
||||
productInfo ProductInfo[] @relation("ProductInfo_Brand")
|
||||
products Product[] @relation("Product_Brand")
|
||||
|
||||
@@map("Product_brands")
|
||||
}
|
||||
@@ -115,7 +111,7 @@ model ProductCategory {
|
||||
updatedAt DateTime @updatedAt @db.Timestamp(0)
|
||||
deletedAt DateTime? @db.Timestamp(0)
|
||||
|
||||
productInfo ProductInfo[] @relation("ProductInfo_Category")
|
||||
products Product[] @relation("Product_Category")
|
||||
|
||||
@@map("Product_categories")
|
||||
}
|
||||
@@ -135,8 +131,6 @@ model Supplier {
|
||||
updatedAt DateTime? @db.Timestamp(0)
|
||||
deletedAt DateTime? @db.Timestamp(0)
|
||||
|
||||
productInfo ProductInfo[] @relation("ProductInfo_Supplier")
|
||||
|
||||
@@map("Suppliers")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user