package com.emotion.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.emotion.common.BaseEntity;
import lombok.Data;
import lombok.experimental.SuperBuilder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * Coze API调用记录实体类
 * 
 * @author huazhongmin
 * @date 2025-07-23
 */
@Data
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("t_coze_api_call")
public class CozeApiCall extends BaseEntity {
    
    /**
     * 对话ID
     */
    @TableField("conversation_id")
    private String conversationId;
    
    /**
     * 消息ID
     */
    @TableField("message_id")
    private String messageId;
    
    /**
     * Coze聊天ID
     */
    @TableField("coze_chat_id")
    private String cozeChatId;
    
    /**
     * Coze对话ID
     */
    @TableField("coze_conversation_id")
    private String cozeConversationId;
    
    /**
     * Bot ID
     */
    @TableField("bot_id")
    private String botId;
    
    /**
     * Workflow ID
     */
    @TableField("workflow_id")
    private String workflowId;
    
    /**
     * 用户ID
     */
    @TableField("user_id")
    private String userId;
    
    /**
     * 请求类型: chat/stream/retrieve/messages
     */
    @TableField("request_type")
    private String requestType;
    
    /**
     * 请求URL
     */
    @TableField("request_url")
    private String requestUrl;
    
    /**
     * 请求体
     */
    @TableField("request_body")
    private String requestBody;
    
    /**
     * 请求头
     */
    @TableField("request_headers")
    private String requestHeaders;
    
    /**
     * 用户输入的消息内容
     */
    @TableField("user_message")
    private String userMessage;
    
    /**
     * 用户消息类型: text/image/file
     */
    @TableField("user_message_type")
    private String userMessageType;
    
    /**
     * AI回复的消息内容
     */
    @TableField("ai_reply")
    private String aiReply;
    
    /**
     * AI回复类型: text/image/file
     */
    @TableField("ai_reply_type")
    private String aiReplyType;
    
    /**
     * HTTP状态码
     */
    @TableField("response_status")
    private Integer responseStatus;
    
    /**
     * 响应体
     */
    @TableField("response_body")
    private String responseBody;
    
    /**
     * 响应头
     */
    @TableField("response_headers")
    private String responseHeaders;
    
    /**
     * 轮询次数
     */
    @TableField("poll_count")
    private Integer pollCount;
    
    /**
     * 轮询开始时间
     */
    @TableField("poll_start_time")
    private LocalDateTime pollStartTime;
    
    /**
     * 轮询结束时间
     */
    @TableField("poll_end_time")
    private LocalDateTime pollEndTime;
    
    /**
     * 最终状态: completed/failed/timeout
     */
    @TableField("final_status")
    private String finalStatus;
    
    /**
     * 调用状态: pending/success/failed/timeout
     */
    @TableField("status")
    private String status;
    
    /**
     * 开始时间
     */
    @TableField("start_time")
    private LocalDateTime startTime;
    
    /**
     * 结束时间
     */
    @TableField("end_time")
    private LocalDateTime endTime;
    
    /**
     * 耗时（毫秒）
     */
    @TableField("duration_ms")
    private Integer durationMs;
    
    /**
     * 输入Token数
     */
    @TableField("prompt_tokens")
    private Integer promptTokens;
    
    /**
     * 输出Token数
     */
    @TableField("completion_tokens")
    private Integer completionTokens;
    
    /**
     * 总Token数
     */
    @TableField("total_tokens")
    private Integer totalTokens;
    
    /**
     * 费用
     */
    @TableField("cost")
    private BigDecimal cost;
    
    /**
     * 函数调用记录
     */
    @TableField("function_calls")
    private String functionCalls;
    
    /**
     * 函数调用结果
     */
    @TableField("function_results")
    private String functionResults;
    
    /**
     * 错误代码
     */
    @TableField("error_code")
    private String errorCode;
    
    /**
     * 错误信息
     */
    @TableField("error_message")
    private String errorMessage;
    
    /**
     * 客户端IP
     */
    @TableField("client_ip")
    private String clientIp;
    
    /**
     * 用户代理
     */
    @TableField("user_agent")
    private String userAgent;
    
    /**
     * 会话ID
     */
    @TableField("session_id")
    private String sessionId;
    
    /**
     * 追踪ID
     */
    @TableField("trace_id")
    private String traceId;
    
    /**
     * 扩展元数据
     */
    @TableField("metadata")
    private String metadata;
}
