use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use uuid::Uuid;

/// A "like" on an article. Composite PK (article, user).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, FromRow)]
pub struct ArticleLikeModel {
    pub article: Uuid,
    pub user: Uuid,
    pub created_at: DateTime<Utc>,
}

/// A comment on an article. Supports nested replies via `parent`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, FromRow)]
pub struct ArticleCommentModel {
    pub id: Uuid,
    pub article: Uuid,
    pub author: Uuid,
    pub parent: Option<Uuid>,
    pub content: String,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub deleted_at: Option<DateTime<Utc>>,
}

/// Payload for creating a comment.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CreateCommentPayload {
    pub content: String,
    pub parent: Option<Uuid>,
}

/// Paginated comment list.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ArticleCommentList {
    pub comments: Vec<ArticleCommentItem>,
    pub total: i64,
}

/// API representation of a comment with author info.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ArticleCommentItem {
    pub id: Uuid,
    pub article: Uuid,
    pub parent: Option<Uuid>,
    pub content: String,
    pub author: Uuid,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}
