Make the house list work
This commit is contained in:
@@ -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
|
||||
)
|
||||
Reference in New Issue
Block a user