23 lines
607 B
Python
23 lines
607 B
Python
# 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
|
|
``` |