from datetime import datetime
from typing import Optional

from pydantic import BaseModel, Field

from app.models.enums import PolicyType


class BasePolicy(BaseModel):
    code: str = Field(..., description="行业代码", example="001")
    name: str = Field(..., description="行业名称", example="农业")
    level: PolicyType = Field(..., description="政策扶持等级", example=PolicyType.A)
    score: int = Field(0, description="政策匹配度基准分", example=90)


class PolicyCreate(BasePolicy):
    pass


class PolicyUpdate(BasePolicy):
    id: int


class PolicyResponse(BasePolicy):
    id: int
    created_at: Optional[datetime]
    updated_at: Optional[datetime]