Add GET endpoint for /luxury

This commit is contained in:
Backend IM Bot 2025-03-25 23:17:51 +00:00
parent 002fecd97a
commit 465239e52b

23
endpoints/luxury.get.py Normal file
View File

@ -0,0 +1,23 @@
# Entity: Hotel
```python
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from typing import List
from core.database import get_db
from models.hotel import Hotel
from schemas.hotel import HotelSchema
router = APIRouter()
@router.get("/luxury", status_code=200, response_model=List[HotelSchema])
async def get_luxury_hotels(
db: Session = Depends(get_db)
):
"""Get luxury hotels in Bahamas"""
luxury_hotels = db.query(Hotel).filter(
Hotel.country == "Bahamas",
Hotel.category == "luxury"
).all()
return luxury_hotels
```