Automated Action 0474b30c3f Implement complete bookstore management API with FastAPI
- Added comprehensive book management with CRUD operations
- Implemented inventory tracking with stock management and reservations
- Created order management system with status tracking
- Integrated Stripe payment processing with payment intents
- Added SQLite database with SQLAlchemy ORM and Alembic migrations
- Implemented health check and API documentation endpoints
- Added comprehensive error handling and validation
- Configured CORS middleware for frontend integration
2025-06-25 10:34:27 +00:00

41 lines
1009 B
Python

from pydantic import BaseModel, Field, EmailStr
from datetime import datetime
from typing import List, Optional
from app.models.order import OrderStatus
class OrderItemBase(BaseModel):
book_id: int
quantity: int = Field(..., gt=0)
class OrderItemCreate(OrderItemBase):
pass
class OrderItemResponse(OrderItemBase):
id: int
price: float
class Config:
from_attributes = True
class OrderBase(BaseModel):
customer_email: EmailStr
customer_name: str = Field(..., min_length=1, max_length=255)
customer_address: str = Field(..., min_length=1)
class OrderCreate(OrderBase):
items: List[OrderItemCreate]
class OrderResponse(OrderBase):
id: int
total_amount: float
status: OrderStatus
stripe_payment_intent_id: Optional[str] = None
items: List[OrderItemResponse]
created_at: datetime
updated_at: Optional[datetime] = None
class Config:
from_attributes = True
class PaymentIntentCreate(BaseModel):
order_id: int