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

#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
pub struct Author {
    pub id: Uuid,
    pub name: String,
    pub created_at: DateTime<Utc>,
}

/// Slimmer shape embedded in manga responses — id + name is all a chip
/// needs to render and link to the author page.
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
pub struct AuthorRef {
    pub id: Uuid,
    pub name: String,
}

/// Returned by `GET /authors/:id`. `manga_count` is denormalized from
/// `manga_authors` so the author page can show it without an extra
/// round-trip.
#[derive(Debug, Clone, Serialize, FromRow)]
pub struct AuthorWithCount {
    pub id: Uuid,
    pub name: String,
    pub created_at: DateTime<Utc>,
    pub manga_count: i64,
}
