Make the house list work

This commit is contained in:
Jacob Windsor
2025-02-19 15:09:45 +01:00
parent cb8b1469cf
commit 6f5a2f422e
3 changed files with 24 additions and 4 deletions
+10 -2
View File
@@ -5,6 +5,7 @@ from ..repositories.house_repository import HouseRepository
from ..models.house import House
from ..dtos.house_create_request import HouseCreateRequest
from ..dtos.house_create_response import HouseCreateResponse
from ..dtos.houses_list_response import HousesListResponse, HouseResponse
router = APIRouter()
@@ -30,5 +31,12 @@ async def create_house(body: HouseCreateRequest, auth: Annotated[AuthContext, De
@router.get("")
async def get_all_houses():
raise NotImplementedError("This endpoint is not implemented yet.")
async def get_all_houses(house_repository: Annotated[HouseRepository, Depends()], limit: int = 100, offset: int = 0) -> HousesListResponse:
all_houses = await house_repository.get_all(offset=offset, limit=limit)
house_responses = ([HouseResponse(id=str(house.id), description=house.description, address=house.address, city=house.city, country=house.country, price=house.price) for house in all_houses])
print(house_responses)
return HousesListResponse(
houses=house_responses
)