26 lines
723 B
Python
26 lines
723 B
Python
# Entity: Lake
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from sqlalchemy.orm import Session
|
|
from app.api.db.database import get_db
|
|
# You'll need to add correct model and schema imports
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/rivers", response_model=List[LakeSchema])
|
|
async def get_lakes_in_paris(
|
|
city: str = "Paris",
|
|
db: Session = Depends(get_db)
|
|
):
|
|
"""
|
|
Get a list of lakes in the specified city.
|
|
|
|
By default, it returns lakes in Paris.
|
|
"""
|
|
lakes = db.query(Lake).filter(Lake.city == city).all()
|
|
|
|
if not lakes:
|
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
|
|
detail=f"No lakes found in {city}")
|
|
|
|
return lakes |