marketplace refactoring
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
# models/api/__init__.py
|
||||
# models/schemas/__init__.py
|
||||
"""API models package - Pydantic models for request/response validation."""
|
||||
|
||||
# Import API model modules
|
||||
from . import base
|
||||
from . import auth
|
||||
from . import product
|
||||
from . import marketplace_product
|
||||
from . import stock
|
||||
from . import shop
|
||||
from . import marketplace
|
||||
from . import marketplace_import_job
|
||||
from . import stats
|
||||
|
||||
# Common imports for convenience
|
||||
@@ -16,9 +16,9 @@ from .base import * # Base Pydantic models
|
||||
__all__ = [
|
||||
"base",
|
||||
"auth",
|
||||
"product",
|
||||
"marketplace_product",
|
||||
"stock",
|
||||
"shop",
|
||||
"marketplace",
|
||||
"marketplace_import_job",
|
||||
"stats",
|
||||
]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# marketplace.py - Keep URL validation, remove business constraints
|
||||
# models/schemas/marketplace_import_job.py - Keep URL validation, remove business constraints
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
class MarketplaceImportRequest(BaseModel):
|
||||
class MarketplaceImportJobRequest(BaseModel):
|
||||
url: str = Field(..., description="URL to CSV file from marketplace")
|
||||
marketplace: str = Field(default="Letzshop", description="Marketplace name")
|
||||
shop_code: str = Field(..., description="Shop code to associate products with")
|
||||
@@ -1,11 +1,11 @@
|
||||
# product.py - Simplified validation
|
||||
# models/schemas/marketplace_products.py - Simplified validation
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from models.schemas.stock import StockSummaryResponse
|
||||
|
||||
class ProductBase(BaseModel):
|
||||
product_id: Optional[str] = None
|
||||
class MarketplaceProductBase(BaseModel):
|
||||
marketplace_product_id: Optional[str] = None
|
||||
title: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
link: Optional[str] = None
|
||||
@@ -45,27 +45,27 @@ class ProductBase(BaseModel):
|
||||
marketplace: Optional[str] = None
|
||||
shop_name: Optional[str] = None
|
||||
|
||||
class ProductCreate(ProductBase):
|
||||
product_id: str = Field(..., description="Product identifier")
|
||||
title: str = Field(..., description="Product title")
|
||||
class MarketplaceProductCreate(MarketplaceProductBase):
|
||||
marketplace_product_id: str = Field(..., description="MarketplaceProduct identifier")
|
||||
title: str = Field(..., description="MarketplaceProduct title")
|
||||
# Removed: min_length constraints and custom validators
|
||||
# Service will handle empty string validation with proper domain exceptions
|
||||
|
||||
class ProductUpdate(ProductBase):
|
||||
class MarketplaceProductUpdate(MarketplaceProductBase):
|
||||
pass
|
||||
|
||||
class ProductResponse(ProductBase):
|
||||
class MarketplaceProductResponse(MarketplaceProductBase):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
id: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class ProductListResponse(BaseModel):
|
||||
products: List[ProductResponse]
|
||||
class MarketplaceProductListResponse(BaseModel):
|
||||
products: List[MarketplaceProductResponse]
|
||||
total: int
|
||||
skip: int
|
||||
limit: int
|
||||
|
||||
class ProductDetailResponse(BaseModel):
|
||||
product: ProductResponse
|
||||
class MarketplaceProductDetailResponse(BaseModel):
|
||||
product: MarketplaceProductResponse
|
||||
stock_info: Optional[StockSummaryResponse] = None
|
||||
@@ -3,7 +3,7 @@ import re
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
from models.schemas.product import ProductResponse
|
||||
from models.schemas.marketplace_product import MarketplaceProductResponse
|
||||
|
||||
class ShopCreate(BaseModel):
|
||||
shop_code: str = Field(..., description="Unique shop identifier")
|
||||
@@ -64,7 +64,7 @@ class ShopListResponse(BaseModel):
|
||||
limit: int
|
||||
|
||||
class ShopProductCreate(BaseModel):
|
||||
product_id: str = Field(..., description="Product ID to add to shop")
|
||||
marketplace_product_id: str = Field(..., description="MarketplaceProduct ID to add to shop")
|
||||
shop_product_id: Optional[str] = None
|
||||
shop_price: Optional[float] = None # Removed: ge=0 constraint
|
||||
shop_sale_price: Optional[float] = None # Removed: ge=0 constraint
|
||||
@@ -80,7 +80,7 @@ class ShopProductResponse(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
id: int
|
||||
shop_id: int
|
||||
product: ProductResponse
|
||||
product: MarketplaceProductResponse
|
||||
shop_product_id: Optional[str]
|
||||
shop_price: Optional[float]
|
||||
shop_sale_price: Optional[float]
|
||||
|
||||
Reference in New Issue
Block a user