add Brand Management

This commit is contained in:
2025-05-26 20:44:15 +02:00
parent d27871160e
commit 25c09dfecc
11 changed files with 548 additions and 21 deletions

View File

@@ -2,10 +2,29 @@ from pydantic import BaseModel, Field
from typing import Optional, List
from datetime import datetime
# Brand schemas
class BrandBase(BaseModel):
name: str
class BrandCreate(BrandBase):
pass
class BrandUpdate(BaseModel):
name: Optional[str] = None
class Brand(BrandBase):
id: int
created_at: datetime
updated_at: Optional[datetime] = None
class Config:
from_attributes = True
# Base schemas
class ProductBase(BaseModel):
name: str
category: str
brand_id: Optional[int] = None
organic: bool = False
weight: Optional[float] = None
weight_unit: str = "g"
@@ -16,6 +35,7 @@ class ProductCreate(ProductBase):
class ProductUpdate(BaseModel):
name: Optional[str] = None
category: Optional[str] = None
brand_id: Optional[int] = None
organic: Optional[bool] = None
weight: Optional[float] = None
weight_unit: Optional[str] = None
@@ -24,6 +44,7 @@ class Product(ProductBase):
id: int
created_at: datetime
updated_at: Optional[datetime] = None
brand: Optional[Brand] = None
class Config:
from_attributes = True
@@ -60,6 +81,7 @@ class ProductWithEventData(BaseModel):
id: int
name: str
category: str
brand: Optional[Brand] = None
organic: bool
weight: Optional[float] = None
weight_unit: str