"""
言迹智能工牌相关Schema定义
"""

from typing import List, Optional

from pydantic import BaseModel, Field


class ConversationMessage(BaseModel):
    """单条对话消息"""

    role: str = Field(..., description="角色：consultant=销售人员，customer=客户")
    text: str = Field(..., description="对话文本内容")
    begin_time: Optional[str] = Field(None, description="开始时间偏移量（毫秒）")
    end_time: Optional[str] = Field(None, description="结束时间偏移量（毫秒）")


class YanjiConversation(BaseModel):
    """完整的对话记录"""

    audio_id: int = Field(..., description="录音ID")
    visit_id: str = Field(..., description="来访单ID")
    start_time: str = Field(..., description="录音开始时间")
    duration: int = Field(..., description="录音时长（毫秒）")
    consultant_name: str = Field(..., description="销售人员姓名")
    consultant_phone: str = Field(..., description="销售人员手机号")
    conversation: List[ConversationMessage] = Field(..., description="对话内容列表")


class GetConversationsByVisitIdsRequest(BaseModel):
    """根据来访单ID获取对话记录请求"""

    external_visit_ids: List[str] = Field(
        ...,
        min_length=1,
        max_length=10,
        description="三方来访单ID列表（最多10个）",
    )


class GetConversationsByVisitIdsResponse(BaseModel):
    """获取对话记录响应"""

    conversations: List[YanjiConversation] = Field(..., description="对话记录列表")
    total: int = Field(..., description="总数量")


class GetConversationsRequest(BaseModel):
    """获取员工对话记录请求"""

    consultant_phone: str = Field(..., description="员工手机号")
    limit: int = Field(default=10, ge=1, le=100, description="获取数量")


class GetConversationsResponse(BaseModel):
    """获取员工对话记录响应"""

    conversations: List[YanjiConversation] = Field(..., description="对话记录列表")
    total: int = Field(..., description="总数量")

