"""Merch MVP API endpoints. Job ID: MTAD-IMPL-2025-11-18-CL""" from fastapi import APIRouter, Depends, HTTPException, status from sqlalchemy.orm import Session from app.database import get_db from app.models import MerchProduct, Order router = APIRouter() @router.get("/products") async def list_products(skip: int = 0, limit: int = 20, db: Session = Depends(get_db)): """List all merch products.""" products = db.query(MerchProduct).offset(skip).limit(limit).all() return {"items": products} @router.get("/products/{product_id}") async def get_product(product_id: str, db: Session = Depends(get_db)): """Get a specific product.""" product = db.query(MerchProduct).filter(MerchProduct.id == product_id).first() if not product: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Product not found") return product @router.get("/orders/{order_id}") async def get_order(order_id: str, db: Session = Depends(get_db)): """Get order details.""" order = db.query(Order).filter(Order.id == order_id).first() if not order: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Order not found") return order @router.post("/products") async def create_product(name: str, price: float, db: Session = Depends(get_db)): """Create product (admin only).""" return {"message": "Product creation not yet implemented"} @router.post("/orders") async def create_order(items: list, db: Session = Depends(get_db)): """Create order (requires authentication).""" return {"message": "Order creation not yet implemented"}