namespace Hc900Crawler.Core.Application.DTOs;

// ── Text-to-SQL DTOs ─────────────────────────────────────────────────────────

public class NaturalLanguageQueryDto
{
    public string Query { get; set; } = string.Empty;
}

public class SqlQueryDto
{
    public string Sql { get; set; } = string.Empty;
    public int? Limit { get; set; } = 1000;
}

public class AnalyzeRequestDto
{
    public List<string> TagNames { get; set; } = new();
    public DateTime? From { get; set; }
    public DateTime? To { get; set; }
    public string Interval { get; set; } = "5 min"; // time_bucket interval
}

public class SqlQueryResultDto
{
    public bool Success { get; set; }
    public string? Error { get; set; }
    public string? Message { get; set; }  // 추가: 조회 결과 메시지
    public List<string> Columns { get; set; } = new();
    public List<Dictionary<string, object?>> Rows { get; set; } = new();
    public int TotalCount { get; set; }
}

/// <summary>MCP query_pv_history 엔드포인트 요청 DTO</summary>
public class HistoryQueryRequestDto
{
    public List<string>? TagNames { get; set; }
    public string? From { get; set; }
    public string? To { get; set; }
    public int? Limit { get; set; }
}

public class TimeSeriesAnalysisDto
{
    public bool Success { get; set; }
    public string? Error { get; set; }
    public List<AnalysisTagResult> Tags { get; set; } = new();
}

public class AnalysisTagResult
{
    public string TagName { get; set; } = string.Empty;
    public double? Avg { get; set; }
    public double? Mean => Avg; // 프론트엔드 호환성을 위한 별칭
    public double? Min { get; set; }
    public double? Max { get; set; }
    public double? First { get; set; }
    public double? Last { get; set; }
    public long PointCount { get; set; }
    public double? StdDev { get; set; } // 표준편차 (추가)
    public DateTime? From { get; set; }
    public DateTime? To { get; set; }
}
