From fc76c60e4a218cf098e570d941aea9062b89bed0 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 25 Mar 2025 23:17:53 +0000 Subject: [PATCH] Add Hotel schema --- schemas/hotel.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 schemas/hotel.py diff --git a/schemas/hotel.py b/schemas/hotel.py new file mode 100644 index 0000000..7a83222 --- /dev/null +++ b/schemas/hotel.py @@ -0,0 +1,48 @@ +from pydantic import BaseModel, Field, EmailStr, HttpUrl +from typing import Optional, List +from decimal import Decimal + +class HotelBase(BaseModel): + name: str = Field(..., min_length=2, max_length=100, description="Hotel name") + description: Optional[str] = Field(None, description="Hotel description") + location: str = Field(..., min_length=2, max_length=100, description="Hotel location") + address: str = Field(..., min_length=5, max_length=200, description="Hotel address") + rating: float = Field(..., ge=0, le=5, description="Hotel rating") + price_per_night: float = Field(..., gt=0, description="Price per night") + amenities: Optional[str] = Field(None, description="Hotel amenities") + images: Optional[str] = Field(None, description="Hotel images") + contact_number: Optional[str] = Field(None, max_length=20, description="Contact number") + email: Optional[EmailStr] = Field(None, description="Hotel email") + website: Optional[HttpUrl] = Field(None, description="Hotel website") + total_rooms: Optional[int] = Field(None, gt=0, description="Total number of rooms") + is_active: bool = Field(default=True, description="Hotel active status") + latitude: Optional[float] = Field(None, ge=-90, le=90, description="Hotel latitude") + longitude: Optional[float] = Field(None, ge=-180, le=180, description="Hotel longitude") + +class HotelCreate(HotelBase): + class Config: + schema_extra = { + "example": { + "name": "Grand Hotel", + "description": "Luxury hotel in the heart of the city", + "location": "New York", + "address": "123 Main Street, New York, NY 10001", + "rating": 4.5, + "price_per_night": 299.99, + "amenities": "WiFi, Pool, Spa, Restaurant", + "images": "hotel1.jpg,hotel2.jpg", + "contact_number": "+1-123-456-7890", + "email": "info@grandhotel.com", + "website": "https://www.grandhotel.com", + "total_rooms": 200, + "is_active": True, + "latitude": 40.7128, + "longitude": -74.0060 + } + } + +class HotelResponse(HotelBase): + id: int = Field(..., description="Hotel ID") + + class Config: + orm_mode = True \ No newline at end of file