"""租户主数据 DTO。"""

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, Field


class TenantCreateDTO(BaseModel):
    """创建租户请求。"""

    tenant_code: str = Field(..., description="租户编码")
    tenant_name: str = Field(..., description="租户名称")
    tenant_short_name: str | None = Field(None, description="租户简称")
    tenant_type: str = Field("CUSTOM", description="租户类型")
    parent_tenant_code: str | None = Field(None, description="父级租户编码")
    display_order: int = Field(0, description="显示顺序")
    is_enabled: bool = Field(True, description="是否启用")
    is_public: bool = Field(False, description="是否公共租户")
    can_host_entry_module: bool = Field(True, description="是否可分配入口模块")
    can_host_documents: bool = Field(True, description="是否可承载文档")
    can_host_rag: bool = Field(True, description="是否可承载知识库")
    can_host_templates: bool = Field(True, description="是否可承载模板")
    feature_keys: list[str] = Field(default_factory=list, description="功能开关键列表")
    alias_values: list[str] = Field(default_factory=list, description="兼容别名列表")
    ext: dict[str, Any] | None = Field(None, description="扩展字段")


class TenantUpdateDTO(BaseModel):
    """更新租户请求。"""

    tenant_name: str | None = Field(None, description="租户名称")
    tenant_short_name: str | None = Field(None, description="租户简称")
    tenant_type: str | None = Field(None, description="租户类型")
    parent_tenant_code: str | None = Field(None, description="父级租户编码")
    display_order: int | None = Field(None, description="显示顺序")
    is_public: bool | None = Field(None, description="是否公共租户")
    can_host_entry_module: bool | None = Field(None, description="是否可分配入口模块")
    can_host_documents: bool | None = Field(None, description="是否可承载文档")
    can_host_rag: bool | None = Field(None, description="是否可承载知识库")
    can_host_templates: bool | None = Field(None, description="是否可承载模板")
    feature_keys: list[str] | None = Field(None, description="功能开关键列表")
    alias_values: list[str] | None = Field(None, description="兼容别名列表")
    ext: dict[str, Any] | None = Field(None, description="扩展字段")


class TenantStatusUpdateDTO(BaseModel):
    """租户启停请求。"""

    is_enabled: bool = Field(..., description="是否启用")
