diff --git a/Makefile b/Makefile index c048a1e..23bf884 100644 --- a/Makefile +++ b/Makefile @@ -16,10 +16,6 @@ start: docker compose down -v db docker compose up --build -clean-db: - docker compose down - docker compose down -v db - clean: rm -rf $(VENV_DIR) diff --git a/backend/app/dtos/house_create_request.py b/backend/app/dtos/house_create_request.py index fff068b..18a2ca7 100644 --- a/backend/app/dtos/house_create_request.py +++ b/backend/app/dtos/house_create_request.py @@ -1,9 +1,9 @@ -from pydantic import BaseModel +from pydantic import BaseModel, Field class HouseCreateRequest(BaseModel): - address: str - city: str - country: str - price: float - description: str + address: str = Field(..., min_length=1, max_length=255, description="House address", examples=["123 Main St"]) + city: str = Field(..., description="City where the house is located", examples=["Springfield"]) + country: str = Field(..., description="Country where the house is located", examples=["USA"]) + price: float = Field(..., description="Price of the house", examples=[250000.00]) + description: str = Field(..., description="Description of the house", examples=["A beautiful 3-bedroom house"]) diff --git a/backend/app/models/house.py b/backend/app/models/house.py index bf8f57b..072b590 100644 --- a/backend/app/models/house.py +++ b/backend/app/models/house.py @@ -8,4 +8,4 @@ class House(SQLModel, table=True): country: str = Field() price: float = Field() description: str = Field() - owner_id: UUID = Field(foreign_key="owner.id") + owner_user_id: UUID = Field(foreign_key="owner.user_id") diff --git a/backend/app/models/owner.py b/backend/app/models/owner.py index 4a192d3..f46a715 100644 --- a/backend/app/models/owner.py +++ b/backend/app/models/owner.py @@ -3,4 +3,4 @@ from uuid import uuid4, UUID class Owner(SQLModel, table=True): id: UUID = Field(default_factory=uuid4, primary_key=True) - user_id: UUID = Field(foreign_key="user.id") + user_id: UUID = Field(foreign_key="user.id", unique=True) diff --git a/backend/app/routers/houses.py b/backend/app/routers/houses.py index 87ee24d..d21b44c 100644 --- a/backend/app/routers/houses.py +++ b/backend/app/routers/houses.py @@ -23,7 +23,7 @@ async def create_house(body: HouseCreateRequest, auth: Annotated[AuthContext, De await owner_repository.save(new_owner) house = House( - owner_id=auth.user.id, + owner_user_id=auth.user.id, address=body.address, city=body.city, country=body.country,