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

use common::entities::Alignment;
use common::entities::Table;
use common::types::EntityId;
use serde::{Deserialize, Serialize};
use std::convert::From;

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct TableDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub cells: Vec<EntityId>,
    pub rows: i64,
    pub columns: i64,
    pub column_widths: Vec<i64>,
    pub fmt_border: Option<i64>,
    pub fmt_cell_spacing: Option<i64>,
    pub fmt_cell_padding: Option<i64>,
    pub fmt_width: Option<i64>,
    pub fmt_alignment: Option<Alignment>,
}

impl From<TableDto> for Table {
    fn from(dto: TableDto) -> Self {
        Table {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            cells: dto.cells,
            rows: dto.rows,
            columns: dto.columns,
            column_widths: dto.column_widths,
            fmt_border: dto.fmt_border,
            fmt_cell_spacing: dto.fmt_cell_spacing,
            fmt_cell_padding: dto.fmt_cell_padding,
            fmt_width: dto.fmt_width,
            fmt_alignment: dto.fmt_alignment,
        }
    }
}

impl From<&TableDto> for Table {
    fn from(dto: &TableDto) -> Self {
        Table {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            cells: dto.cells.clone(),
            rows: dto.rows,
            columns: dto.columns,
            column_widths: dto.column_widths.clone(),
            fmt_border: dto.fmt_border,
            fmt_cell_spacing: dto.fmt_cell_spacing,
            fmt_cell_padding: dto.fmt_cell_padding,
            fmt_width: dto.fmt_width,
            fmt_alignment: dto.fmt_alignment.clone(),
        }
    }
}

impl From<Table> for TableDto {
    fn from(entity: Table) -> Self {
        TableDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            cells: entity.cells,
            rows: entity.rows,
            columns: entity.columns,
            column_widths: entity.column_widths,
            fmt_border: entity.fmt_border,
            fmt_cell_spacing: entity.fmt_cell_spacing,
            fmt_cell_padding: entity.fmt_cell_padding,
            fmt_width: entity.fmt_width,
            fmt_alignment: entity.fmt_alignment,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct CreateTableDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub cells: Vec<EntityId>,
    pub rows: i64,
    pub columns: i64,
    pub column_widths: Vec<i64>,
    pub fmt_border: Option<i64>,
    pub fmt_cell_spacing: Option<i64>,
    pub fmt_cell_padding: Option<i64>,
    pub fmt_width: Option<i64>,
    pub fmt_alignment: Option<Alignment>,
}

impl From<CreateTableDto> for Table {
    fn from(dto: CreateTableDto) -> Self {
        Table {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            cells: dto.cells,
            rows: dto.rows,
            columns: dto.columns,
            column_widths: dto.column_widths,
            fmt_border: dto.fmt_border,
            fmt_cell_spacing: dto.fmt_cell_spacing,
            fmt_cell_padding: dto.fmt_cell_padding,
            fmt_width: dto.fmt_width,
            fmt_alignment: dto.fmt_alignment,
        }
    }
}

impl From<&CreateTableDto> for Table {
    fn from(dto: &CreateTableDto) -> Self {
        Table {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            cells: dto.cells.clone(),
            rows: dto.rows,
            columns: dto.columns,
            column_widths: dto.column_widths.clone(),
            fmt_border: dto.fmt_border,
            fmt_cell_spacing: dto.fmt_cell_spacing,
            fmt_cell_padding: dto.fmt_cell_padding,
            fmt_width: dto.fmt_width,
            fmt_alignment: dto.fmt_alignment.clone(),
        }
    }
}

impl From<Table> for CreateTableDto {
    fn from(entity: Table) -> Self {
        CreateTableDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            cells: entity.cells,
            rows: entity.rows,
            columns: entity.columns,
            column_widths: entity.column_widths,
            fmt_border: entity.fmt_border,
            fmt_cell_spacing: entity.fmt_cell_spacing,
            fmt_cell_padding: entity.fmt_cell_padding,
            fmt_width: entity.fmt_width,
            fmt_alignment: entity.fmt_alignment,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct UpdateTableDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub rows: i64,
    pub columns: i64,
    pub column_widths: Vec<i64>,
    pub fmt_border: Option<i64>,
    pub fmt_cell_spacing: Option<i64>,
    pub fmt_cell_padding: Option<i64>,
    pub fmt_width: Option<i64>,
    pub fmt_alignment: Option<Alignment>,
}

impl From<UpdateTableDto> for Table {
    fn from(dto: UpdateTableDto) -> Self {
        Table {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            rows: dto.rows,
            columns: dto.columns,
            column_widths: dto.column_widths,
            fmt_border: dto.fmt_border,
            fmt_cell_spacing: dto.fmt_cell_spacing,
            fmt_cell_padding: dto.fmt_cell_padding,
            fmt_width: dto.fmt_width,
            fmt_alignment: dto.fmt_alignment,
            cells: Default::default(),
        }
    }
}

impl From<&UpdateTableDto> for Table {
    fn from(dto: &UpdateTableDto) -> Self {
        Table {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            rows: dto.rows,
            columns: dto.columns,
            column_widths: dto.column_widths.clone(),
            fmt_border: dto.fmt_border,
            fmt_cell_spacing: dto.fmt_cell_spacing,
            fmt_cell_padding: dto.fmt_cell_padding,
            fmt_width: dto.fmt_width,
            fmt_alignment: dto.fmt_alignment.clone(),
            cells: Default::default(),
        }
    }
}

impl From<Table> for UpdateTableDto {
    fn from(entity: Table) -> Self {
        UpdateTableDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            rows: entity.rows,
            columns: entity.columns,
            column_widths: entity.column_widths,
            fmt_border: entity.fmt_border,
            fmt_cell_spacing: entity.fmt_cell_spacing,
            fmt_cell_padding: entity.fmt_cell_padding,
            fmt_width: entity.fmt_width,
            fmt_alignment: entity.fmt_alignment,
        }
    }
}

impl From<TableDto> for UpdateTableDto {
    fn from(dto: TableDto) -> Self {
        UpdateTableDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            rows: dto.rows,
            columns: dto.columns,
            column_widths: dto.column_widths,
            fmt_border: dto.fmt_border,
            fmt_cell_spacing: dto.fmt_cell_spacing,
            fmt_cell_padding: dto.fmt_cell_padding,
            fmt_width: dto.fmt_width,
            fmt_alignment: dto.fmt_alignment,
        }
    }
}
pub use common::direct_access::table::TableRelationshipField;

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