// Generated by Qleany v1.5.1 from entity_dtos.tera

use common::entities::Document;
pub use common::entities::TextDirection;
pub use common::entities::WrapMode;
use common::types::EntityId;
use serde::{Deserialize, Serialize};
use std::convert::From;

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct DocumentDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub title: String,
    pub frames: Vec<EntityId>,
    pub text_direction: TextDirection,
    pub default_wrap_mode: WrapMode,
    pub resources: Vec<EntityId>,
    pub lists: Vec<EntityId>,
    pub tables: Vec<EntityId>,
    pub character_count: i64,
    pub block_count: i64,
}

impl From<DocumentDto> for Document {
    fn from(dto: DocumentDto) -> Self {
        Document {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            title: dto.title,
            frames: dto.frames,
            text_direction: dto.text_direction,
            default_wrap_mode: dto.default_wrap_mode,
            resources: dto.resources,
            lists: dto.lists,
            tables: dto.tables,
            character_count: dto.character_count,
            block_count: dto.block_count,
        }
    }
}

impl From<&DocumentDto> for Document {
    fn from(dto: &DocumentDto) -> Self {
        Document {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            title: dto.title.clone(),
            frames: dto.frames.clone(),
            text_direction: dto.text_direction.clone(),
            default_wrap_mode: dto.default_wrap_mode.clone(),
            resources: dto.resources.clone(),
            lists: dto.lists.clone(),
            tables: dto.tables.clone(),
            character_count: dto.character_count,
            block_count: dto.block_count,
        }
    }
}

impl From<Document> for DocumentDto {
    fn from(entity: Document) -> Self {
        DocumentDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            title: entity.title,
            frames: entity.frames,
            text_direction: entity.text_direction,
            default_wrap_mode: entity.default_wrap_mode,
            resources: entity.resources,
            lists: entity.lists,
            tables: entity.tables,
            character_count: entity.character_count,
            block_count: entity.block_count,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct CreateDocumentDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub title: String,
    pub frames: Vec<EntityId>,
    pub text_direction: TextDirection,
    pub default_wrap_mode: WrapMode,
    pub resources: Vec<EntityId>,
    pub lists: Vec<EntityId>,
    pub tables: Vec<EntityId>,
    pub character_count: i64,
    pub block_count: i64,
}

impl From<CreateDocumentDto> for Document {
    fn from(dto: CreateDocumentDto) -> Self {
        Document {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            title: dto.title,
            frames: dto.frames,
            text_direction: dto.text_direction,
            default_wrap_mode: dto.default_wrap_mode,
            resources: dto.resources,
            lists: dto.lists,
            tables: dto.tables,
            character_count: dto.character_count,
            block_count: dto.block_count,
        }
    }
}

impl From<&CreateDocumentDto> for Document {
    fn from(dto: &CreateDocumentDto) -> Self {
        Document {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            title: dto.title.clone(),
            frames: dto.frames.clone(),
            text_direction: dto.text_direction.clone(),
            default_wrap_mode: dto.default_wrap_mode.clone(),
            resources: dto.resources.clone(),
            lists: dto.lists.clone(),
            tables: dto.tables.clone(),
            character_count: dto.character_count,
            block_count: dto.block_count,
        }
    }
}

impl From<Document> for CreateDocumentDto {
    fn from(entity: Document) -> Self {
        CreateDocumentDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            title: entity.title,
            frames: entity.frames,
            text_direction: entity.text_direction,
            default_wrap_mode: entity.default_wrap_mode,
            resources: entity.resources,
            lists: entity.lists,
            tables: entity.tables,
            character_count: entity.character_count,
            block_count: entity.block_count,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct UpdateDocumentDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub title: String,
    pub text_direction: TextDirection,
    pub default_wrap_mode: WrapMode,
    pub character_count: i64,
    pub block_count: i64,
}

impl From<UpdateDocumentDto> for Document {
    fn from(dto: UpdateDocumentDto) -> Self {
        Document {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            title: dto.title,
            text_direction: dto.text_direction,
            default_wrap_mode: dto.default_wrap_mode,
            character_count: dto.character_count,
            block_count: dto.block_count,
            frames: Default::default(),
            resources: Default::default(),
            lists: Default::default(),
            tables: Default::default(),
        }
    }
}

impl From<&UpdateDocumentDto> for Document {
    fn from(dto: &UpdateDocumentDto) -> Self {
        Document {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            title: dto.title.clone(),
            text_direction: dto.text_direction.clone(),
            default_wrap_mode: dto.default_wrap_mode.clone(),
            character_count: dto.character_count,
            block_count: dto.block_count,
            frames: Default::default(),
            resources: Default::default(),
            lists: Default::default(),
            tables: Default::default(),
        }
    }
}

impl From<Document> for UpdateDocumentDto {
    fn from(entity: Document) -> Self {
        UpdateDocumentDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            title: entity.title,
            text_direction: entity.text_direction,
            default_wrap_mode: entity.default_wrap_mode,
            character_count: entity.character_count,
            block_count: entity.block_count,
        }
    }
}

impl From<DocumentDto> for UpdateDocumentDto {
    fn from(dto: DocumentDto) -> Self {
        UpdateDocumentDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            title: dto.title,
            text_direction: dto.text_direction,
            default_wrap_mode: dto.default_wrap_mode,
            character_count: dto.character_count,
            block_count: dto.block_count,
        }
    }
}
pub use common::direct_access::document::DocumentRelationshipField;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DocumentRelationshipDto {
    pub id: EntityId,
    pub field: DocumentRelationshipField,
    pub right_ids: Vec<EntityId>,
}
