use chrono::{DateTime, NaiveDate, Utc};
use serde_json::Value as JsonValue;
use sqlx::FromRow;
use uuid::Uuid;

#[derive(Debug, Clone, FromRow)]
pub struct CompanyProfile {
    pub symbol: String,
    pub name: String,
    pub industry: Option<String>,
    pub list_date: Option<NaiveDate>,
    pub additional_info: Option<JsonValue>,
    pub updated_at: DateTime<Utc>,
}

#[derive(Debug, Clone, FromRow)]
pub struct TimeSeriesFinancial {
    pub symbol: String,
    pub metric_name: String,
    pub period_date: NaiveDate,
    pub value: rust_decimal::Decimal,
    pub source: Option<String>,
}

#[derive(Debug, Clone, FromRow)]
pub struct DailyMarketData {
    pub symbol: String,
    pub trade_date: NaiveDate,
    pub open_price: Option<rust_decimal::Decimal>,
    pub high_price: Option<rust_decimal::Decimal>,
    pub low_price: Option<rust_decimal::Decimal>,
    pub close_price: Option<rust_decimal::Decimal>,
    pub volume: Option<i64>,
    pub pe: Option<rust_decimal::Decimal>,
    pub pb: Option<rust_decimal::Decimal>,
    pub total_mv: Option<rust_decimal::Decimal>,
}

// AnalysisResult struct removed as it is deprecated and table is dropped.


#[derive(Debug, Clone, FromRow)]
pub struct SystemConfig {
    pub config_key: String,
    pub config_value: JsonValue,
    pub description: Option<String>,
    pub updated_at: DateTime<Utc>,
}

#[derive(Debug, Clone, FromRow)]
pub struct ExecutionLog {
    pub id: i64,
    pub report_id: Uuid,
    pub step_name: String,
    pub status: String,
    pub start_time: DateTime<Utc>,
    pub end_time: Option<DateTime<Utc>>,
    pub duration_ms: Option<i32>,
    pub token_usage: Option<JsonValue>,
    pub error_message: Option<String>,
    pub log_details: Option<JsonValue>,
}

#[derive(Debug, Clone, FromRow)]
pub struct RealtimeQuote {
    pub symbol: String,
    pub market: String,
    pub ts: DateTime<Utc>,
    pub price: rust_decimal::Decimal,
    pub open_price: Option<rust_decimal::Decimal>,
    pub high_price: Option<rust_decimal::Decimal>,
    pub low_price: Option<rust_decimal::Decimal>,
    pub prev_close: Option<rust_decimal::Decimal>,
    pub change: Option<rust_decimal::Decimal>,
    pub change_percent: Option<rust_decimal::Decimal>,
    pub volume: Option<i64>,
    pub source: Option<String>,
    pub updated_at: DateTime<Utc>,
}


