"""入口模块管理 DTO。"""

from pydantic import BaseModel, Field


class EntryModuleAreaDTO(BaseModel):
    """入口模块历史地区配置，仅用于兼容旧请求。"""

    area: str = Field(..., description="地区名称")
    enabled: bool = Field(True, description="是否启用")
    sort_order: int = Field(0, description="排序号")


class EntryModuleTenantDTO(BaseModel):
    """入口模块租户配置。"""

    tenant_code: str = Field(..., description="租户编码")
    tenant_name: str | None = Field(None, description="租户名称")
    enabled: bool = Field(True, description="是否启用")
    sort_order: int = Field(0, description="排序号")


class EntryModuleCreateDTO(BaseModel):
    """创建入口模块请求。"""

    name: str = Field(..., description="模块名称")
    description: str | None = Field(None, description="模块描述")
    path: str | None = Field(None, description="前端路由路径")
    route_path: str | None = Field(None, description="前端跳转路径")
    areas: list[EntryModuleAreaDTO] | None = Field(None, description="历史地区配置（兼容字段，建议改用 tenants）")
    tenants: list[EntryModuleTenantDTO] | None = Field(None, description="租户配置")


class EntryModuleUpdateDTO(BaseModel):
    """更新入口模块请求。"""

    name: str | None = Field(None, description="模块名称")
    description: str | None = Field(None, description="模块描述")
    path: str | None = Field(None, description="前端路由路径")
    route_path: str | None = Field(None, description="前端跳转路径")
    areas: list[EntryModuleAreaDTO] | None = Field(None, description="历史地区配置（兼容字段，建议改用 tenants）")
    tenants: list[EntryModuleTenantDTO] | None = Field(None, description="租户配置")
