Add GET endpoint for /luxury
This commit is contained in:
parent
002fecd97a
commit
465239e52b
23
endpoints/luxury.get.py
Normal file
23
endpoints/luxury.get.py
Normal 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
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user