24 lines
717 B
Python
24 lines
717 B
Python
"""
|
|
@router ProductCompareRouter (Backend/app/api/v1/routers/ProductCompareRouter.py)
|
|
"""
|
|
from fastapi import APIRouter
|
|
from pydantic import BaseModel
|
|
from typing import List
|
|
|
|
router = APIRouter(prefix="/api/v1/products/compare", tags=["Product Comparison Matrix"])
|
|
|
|
class CompareRequest(BaseModel):
|
|
product_ids: List[str]
|
|
|
|
@router.post("")
|
|
def compare_products(payload: CompareRequest):
|
|
return {
|
|
"attributes": ["Screen Size", "RAM", "Price"],
|
|
"products": [
|
|
{
|
|
"product_id": pid,
|
|
"name": f"Product {pid}",
|
|
"values": {"Screen Size": "6.1 in", "RAM": "N/A", "Price": 149.99}
|
|
} for pid in payload.product_ids
|
|
]
|
|
}
|