
- Implemented user authentication with JWT tokens - Created product management endpoints - Added shopping cart functionality - Implemented order management system - Setup database models with SQLAlchemy - Created alembic migrations - Added health check endpoint generated with BackendIM... (backend.im)
36 lines
732 B
Python
36 lines
732 B
Python
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ProductBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
price: float = Field(..., gt=0)
|
|
stock: int = Field(..., ge=0)
|
|
image_url: Optional[str] = None
|
|
is_active: bool = True
|
|
|
|
|
|
class ProductCreate(ProductBase):
|
|
pass
|
|
|
|
|
|
class ProductUpdate(BaseModel):
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
price: Optional[float] = Field(None, gt=0)
|
|
stock: Optional[int] = Field(None, ge=0)
|
|
image_url: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class ProductInDBBase(ProductBase):
|
|
id: int
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class Product(ProductInDBBase):
|
|
pass |