package com.cy.guoyan.admin.module.ai.controller.admin.chatmessage.vo;

import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import javax.validation.constraints.*;
import java.time.LocalDateTime;

@Schema(description = "管理后台 - AI聊天消息新增/修改 Request VO")
@Data
public class ChatMessageSaveReqVO {

    @Schema(description = "主键 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9107")
    private Long id;

    @Schema(description = "会话 ID（关联 bdcmd_chat_session.id）", requiredMode = Schema.RequiredMode.REQUIRED, example = "27820")
    @NotNull(message = "会话 ID（关联 bdcmd_chat_session.id）不能为空")
    private Long sessionId;

    @Schema(description = "用户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "8634")
    @NotNull(message = "用户 ID不能为空")
    private String userId;

    @Schema(description = "发送方角色：user / assistant / system / tool", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "发送方角色：user / assistant / system / tool不能为空")
    private String role;

    @Schema(description = "消息内容（支持 markdown / text / 部分 HTML）")
    private String content;

    @Schema(description = "消息发送时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "消息发送时间不能为空")
    private LocalDateTime messageTime;

    @Schema(description = "Dify 消息唯一 ID（message_id）", example = "8251")
    private String difyMessageId;

    @Schema(description = "Dify 任务 ID（task_id）", example = "2681")
    private String difyTaskId;

    @Schema(description = "Dify 事件类型，如 message, message_end 等")
    private String difyEvent;

    @Schema(description = "Dify 会话 ID", example = "15161")
    private String difyConversationId;

    @Schema(description = "Dify 消息创建时间戳")
    private Long createdTimestamp;

    @Schema(description = "Agent 思考内容（仅 Agent 模式）")
    private String agentThought;

    @Schema(description = "Agent 工具调用返回结果")
    private String agentObservation;

    @Schema(description = "使用的工具名，多个用 ; 分隔")
    private String agentTool;

    @Schema(description = "工具输入（JSON 字符串）")
    private String agentToolInput;

    @Schema(description = "文件 ID 列表，JSON数组格式")
    private String fileIds;

    @Schema(description = "文件 URL 列表，JSON数组格式，仅 assistant 角色可用")
    private String fileUrls;

    @Schema(description = "状态：streaming / completed / error", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
    @NotEmpty(message = "状态：streaming / completed / error不能为空")
    private String status;

    @Schema(description = "是否对用户可见", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "是否对用户可见不能为空")
    private Boolean isVisible;

    @Schema(description = "元数据 JSON（如使用模型、引用信息等）")
    private JSONObject metadataJson;

    @Schema(description = "模型用量 JSON（如 tokens 消耗）")
    private JSONObject usageJson;

    @Schema(description = "完整 Dify 响应 JSON（用于调试和回放）")
    private JSONObject responseJson;

}