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

40 lines
1.4 KiB
Python

from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional
class BookBase(BaseModel):
title: str = Field(..., min_length=1, max_length=255)
author: str = Field(..., min_length=1, max_length=255)
isbn: str = Field(..., min_length=10, max_length=13)
description: Optional[str] = None
price: float = Field(..., gt=0)
category: str = Field(..., min_length=1, max_length=100)
publisher: Optional[str] = None
publication_date: Optional[datetime] = None
pages: Optional[int] = Field(None, gt=0)
language: str = Field(default="English", max_length=50)
class BookCreate(BookBase):
pass
class BookUpdate(BaseModel):
title: Optional[str] = Field(None, min_length=1, max_length=255)
author: Optional[str] = Field(None, min_length=1, max_length=255)
isbn: Optional[str] = Field(None, min_length=10, max_length=13)
description: Optional[str] = None
price: Optional[float] = Field(None, gt=0)
category: Optional[str] = Field(None, min_length=1, max_length=100)
publisher: Optional[str] = None
publication_date: Optional[datetime] = None
pages: Optional[int] = Field(None, gt=0)
language: Optional[str] = Field(None, max_length=50)
is_active: Optional[bool] = None
class BookResponse(BookBase):
id: int
is_active: bool
created_at: datetime
updated_at: Optional[datetime] = None
class Config:
from_attributes = True