Automated Action 9ca9d35a1a Implement complete Urban Real Estate API backend
- Set up FastAPI project structure with modular architecture
- Create comprehensive database models for users, properties, messages, notifications, and payments
- Implement JWT-based authentication with role-based access control (Seeker, Agent, Landlord, Admin)
- Build property listings CRUD with advanced search and filtering capabilities
- Add dedicated affordable housing endpoints for Nigerian market focus
- Create real-time messaging system between users
- Implement admin dashboard with property approval workflow and analytics
- Add notification system for user alerts
- Integrate Paystack payment gateway for transactions
- Set up SQLite database with Alembic migrations
- Include comprehensive health check and API documentation
- Add proper error handling and validation throughout
- Follow FastAPI best practices with Pydantic schemas and dependency injection
2025-06-27 12:24:06 +00:00

32 lines
1.0 KiB
Python

from typing import List
from fastapi import APIRouter, Depends, Query
from sqlalchemy.orm import Session
from app.auth.dependencies import get_db
from app.models.property import PropertyListing
from app.schemas.property import PropertyResponse
router = APIRouter(prefix="/api/affordable", tags=["Affordable Housing"])
@router.get("/", response_model=List[PropertyResponse])
def get_affordable_properties(
skip: int = Query(0, ge=0),
limit: int = Query(100, ge=1, le=100),
state: str = Query(None),
max_price: float = Query(None, ge=0),
db: Session = Depends(get_db)
):
query = db.query(PropertyListing).filter(
PropertyListing.is_affordable,
PropertyListing.is_active,
PropertyListing.is_approved
)
if state:
query = query.filter(PropertyListing.state.ilike(f"%{state}%"))
if max_price is not None:
query = query.filter(PropertyListing.price <= max_price)
properties = query.order_by(PropertyListing.price.asc()).offset(skip).limit(limit).all()
return properties