from typing import Optional, List, Dict
from pydantic import BaseModel, Field


class AnnouncementCreate(BaseModel):
    house_nm: str
    house_secd: str = "01"
    house_dtl_secd: Optional[str] = None
    rent_secd: Optional[str] = None
    region_code: Optional[str] = None
    region_name: Optional[str] = None
    address: Optional[str] = None
    total_units: Optional[int] = None
    rcrit_date: Optional[str] = None
    receipt_start: Optional[str] = None
    receipt_end: Optional[str] = None
    spsply_start: Optional[str] = None
    spsply_end: Optional[str] = None
    gnrl_rank1_start: Optional[str] = None
    gnrl_rank1_end: Optional[str] = None
    winner_date: Optional[str] = None
    contract_start: Optional[str] = None
    contract_end: Optional[str] = None
    homepage_url: Optional[str] = None
    pblanc_url: Optional[str] = None
    constructor: Optional[str] = None
    developer: Optional[str] = None
    move_in_month: Optional[str] = None
    is_speculative_area: Optional[str] = None
    is_price_cap: Optional[str] = None
    contact: Optional[str] = None


class AnnouncementUpdate(BaseModel):
    house_nm: Optional[str] = None
    house_secd: Optional[str] = None
    house_dtl_secd: Optional[str] = None
    rent_secd: Optional[str] = None
    region_code: Optional[str] = None
    region_name: Optional[str] = None
    address: Optional[str] = None
    total_units: Optional[int] = None
    rcrit_date: Optional[str] = None
    receipt_start: Optional[str] = None
    receipt_end: Optional[str] = None
    spsply_start: Optional[str] = None
    spsply_end: Optional[str] = None
    gnrl_rank1_start: Optional[str] = None
    gnrl_rank1_end: Optional[str] = None
    winner_date: Optional[str] = None
    contract_start: Optional[str] = None
    contract_end: Optional[str] = None
    homepage_url: Optional[str] = None
    pblanc_url: Optional[str] = None
    constructor: Optional[str] = None
    developer: Optional[str] = None
    move_in_month: Optional[str] = None
    is_speculative_area: Optional[str] = None
    is_price_cap: Optional[str] = None
    contact: Optional[str] = None


class ProfileUpdate(BaseModel):
    name: Optional[str] = None
    age: Optional[int] = None
    is_homeless: Optional[bool] = None
    is_householder: Optional[bool] = None
    subscription_months: Optional[int] = None
    subscription_amount: Optional[int] = None
    family_members: Optional[int] = None
    has_dependents: Optional[bool] = None
    children_count: Optional[int] = None
    is_newlywed: Optional[bool] = None
    marriage_months: Optional[int] = None
    has_newborn: Optional[bool] = None
    is_first_home: Optional[bool] = None
    income_level: Optional[str] = None
    preferred_regions: Optional[List[str]] = None
    preferred_types: Optional[List[str]] = None
    min_area: Optional[float] = None
    max_area: Optional[float] = None
    max_price: Optional[int] = None
    # 신규
    preferred_districts: Optional[Dict[str, List[str]]] = None
    min_match_score: Optional[int] = Field(default=None, ge=0, le=100)
    notify_enabled: Optional[bool] = None


class ListingCriteriaUpdate(BaseModel):
    dongs: Optional[List[str]] = None
    deal_types: Optional[List[str]] = None
    max_deposit: Optional[int] = None
    max_sale_price: Optional[int] = None
    min_area: Optional[float] = None
    house_types: Optional[List[str]] = None
    min_safety_tier: Optional[str] = None
    notify_enabled: Optional[bool] = None
    equity: Optional[int] = None
    annual_income: Optional[int] = None
    is_homeless: Optional[bool] = None
    is_householder: Optional[bool] = None
    is_first_home: Optional[bool] = None


class SafetyCheckRequest(BaseModel):
    complex_name: Optional[str] = None
    address: Optional[str] = None
    dong: Optional[str] = None
    dong_code: Optional[str] = None
    area: float
    deal_type: str
    amount: int


class BudgetRequest(BaseModel):
    equity: int
    annual_income: int
    is_homeless: bool = True
    is_householder: bool = False
    is_first_home: bool = False
    target_dong: Optional[str] = None
