"""RBAC 路由 VO。"""

from __future__ import annotations

from pydantic import BaseModel, Field


class RbacRouteVO(BaseModel):
    """当前用户可访问的前端路由。"""

    id: int = Field(..., description="路由ID")
    route_path: str = Field(..., description="前端路由路径")
    route_name: str = Field(..., description="路由名称")
    component: str | None = Field(None, description="前端组件路径")
    parent_id: int | None = Field(None, description="父路由ID")
    route_title: str = Field(..., description="路由标题")
    icon: str | None = Field(None, description="路由图标")
    sort_order: int = Field(0, description="排序顺序")
    is_hidden: bool = Field(False, description="是否隐藏")
    is_cache: bool = Field(False, description="是否开启缓存")
    meta: dict | None = Field(None, description="路由扩展元数据")
    permissions: list[str] = Field(default_factory=list, description="当前用户在该路由下拥有的权限列表")
    children: list["RbacRouteVO"] | None = Field(None, description="子路由")


class RbacUserRoutesVO(BaseModel):
    """当前用户路由响应。"""

    user_id: int = Field(..., description="用户ID")
    username: str = Field(..., description="用户名")
    roles: list[str] = Field(default_factory=list, description="用户角色列表")
    routes: list[RbacRouteVO] = Field(default_factory=list, description="用户可访问路由树")


RbacRouteVO.model_rebuild()
