mirror of
http://88.130.71.182:3000/BlitTech/badoHair_be.git
synced 2026-06-12 23:23:22 +00:00
Initial Commit
This commit is contained in:
70
app/models/products.py
Normal file
70
app/models/products.py
Normal file
@@ -0,0 +1,70 @@
|
||||
from typing import Literal
|
||||
from pydantic import BaseModel, Field
|
||||
from uuid import UUID
|
||||
from datetime import datetime
|
||||
|
||||
ProductCategory = Literal["clip-in", "tape-in", "ponytail", "keratin"]
|
||||
|
||||
|
||||
class ProductCreate(BaseModel):
|
||||
name: str = Field(min_length=1, max_length=200)
|
||||
description: str | None = None
|
||||
price: float = Field(gt=0)
|
||||
original_price: float | None = Field(None, gt=0)
|
||||
category: ProductCategory | None = None
|
||||
colors: list[str] = []
|
||||
lengths: list[str] = []
|
||||
features: list[str] = []
|
||||
stock_quantity: int = Field(ge=0, default=0)
|
||||
is_featured: bool = False
|
||||
is_hidden: bool = False
|
||||
is_new: bool = False
|
||||
is_bestseller: bool = False
|
||||
|
||||
|
||||
class ProductUpdate(BaseModel):
|
||||
name: str | None = Field(None, min_length=1, max_length=200)
|
||||
description: str | None = None
|
||||
price: float | None = Field(None, gt=0)
|
||||
original_price: float | None = Field(None, gt=0)
|
||||
category: ProductCategory | None = None
|
||||
colors: list[str] | None = None
|
||||
lengths: list[str] | None = None
|
||||
features: list[str] | None = None
|
||||
stock_quantity: int | None = Field(None, ge=0)
|
||||
is_featured: bool | None = None
|
||||
is_hidden: bool | None = None
|
||||
is_new: bool | None = None
|
||||
is_bestseller: bool | None = None
|
||||
|
||||
|
||||
class StockUpdate(BaseModel):
|
||||
id: UUID
|
||||
stock_quantity: int = Field(ge=0)
|
||||
|
||||
|
||||
class BulkStockUpdateRequest(BaseModel):
|
||||
updates: list[StockUpdate]
|
||||
|
||||
|
||||
class ProductOut(BaseModel):
|
||||
id: UUID
|
||||
name: str
|
||||
description: str | None = None
|
||||
price: float
|
||||
original_price: float | None = None
|
||||
category: str | None = None
|
||||
image: str = ""
|
||||
images: list[str] = []
|
||||
colors: list[str] = []
|
||||
lengths: list[str] = []
|
||||
features: list[str] = []
|
||||
stock_quantity: int
|
||||
is_featured: bool
|
||||
is_hidden: bool
|
||||
is_new: bool
|
||||
is_bestseller: bool
|
||||
rating: float = 0
|
||||
review_count: int = 0
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
Reference in New Issue
Block a user