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


#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, FromRow)]
pub struct ChannelArticleModel {
    pub id: Uuid,
    pub channel: Uuid,
    pub author: Uuid,
    pub title: String,
    pub cover_url: Option<String>,
    pub content: String,
    pub content_type: String,
    pub summary: Option<String>,
    #[serde(default)]
    pub tags: Vec<String>,
    pub is_pinned: bool,
    pub view_count: i64,
    pub like_count: i64,
    pub comment_count: i64,
    pub status: String,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
    pub deleted_at: Option<DateTime<Utc>>,
}


#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CreateArticlePayload {
    pub channel: Uuid,
    pub title: String,
    pub cover_url: Option<String>,
    pub content: String,
    pub content_type: Option<String>,
    pub summary: Option<String>,
    pub tags: Option<Vec<String>>,
    pub status: Option<String>,
}


#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UpdateArticlePayload {
    pub title: Option<String>,
    pub cover_url: Option<String>,
    pub content: Option<String>,
    pub content_type: Option<String>,
    pub summary: Option<String>,
    pub tags: Option<Vec<String>>,
    pub is_pinned: Option<bool>,
    pub status: Option<String>,
}


#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
pub struct ChannelArticleCard {
    pub id: Uuid,
    pub channel: Uuid,
    pub author: Uuid,
    pub title: String,
    pub cover_url: Option<String>,
    pub summary: Option<String>,
    pub tags: Vec<String>,
    pub like_count: i64,
    pub comment_count: i64,
    pub view_count: i64,
    pub created_at: DateTime<Utc>,
}
