from datetime import date, datetime
from typing import Optional

from pydantic import BaseModel, Field


class KeywordBase(BaseModel):
    city: str = Field(..., max_length=64, description="城市")
    job: str = Field(..., max_length=128, description="职位关键词")


class KeywordCreate(KeywordBase):
    pass


class KeywordUpdate(BaseModel):
    city: Optional[str] = Field(None, max_length=64, description="城市")
    job: Optional[str] = Field(None, max_length=128, description="职位关键词")


class KeywordOut(KeywordBase):
    id: int
    last_requested_date: Optional[date] = None
    last_requested_at: Optional[datetime] = None
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True
