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

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

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct TableCellDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub row: i64,
    pub column: i64,
    pub row_span: i64,
    pub column_span: i64,
    pub cell_frame: Option<EntityId>,
    pub fmt_padding: Option<i64>,
    pub fmt_border: Option<i64>,
    pub fmt_vertical_alignment: Option<CellVerticalAlignment>,
    pub fmt_background_color: Option<String>,
}

impl From<TableCellDto> for TableCell {
    fn from(dto: TableCellDto) -> Self {
        TableCell {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            row: dto.row,
            column: dto.column,
            row_span: dto.row_span,
            column_span: dto.column_span,
            cell_frame: dto.cell_frame,
            fmt_padding: dto.fmt_padding,
            fmt_border: dto.fmt_border,
            fmt_vertical_alignment: dto.fmt_vertical_alignment,
            fmt_background_color: dto.fmt_background_color,
        }
    }
}

impl From<&TableCellDto> for TableCell {
    fn from(dto: &TableCellDto) -> Self {
        TableCell {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            row: dto.row,
            column: dto.column,
            row_span: dto.row_span,
            column_span: dto.column_span,
            cell_frame: dto.cell_frame,
            fmt_padding: dto.fmt_padding,
            fmt_border: dto.fmt_border,
            fmt_vertical_alignment: dto.fmt_vertical_alignment.clone(),
            fmt_background_color: dto.fmt_background_color.clone(),
        }
    }
}

impl From<TableCell> for TableCellDto {
    fn from(entity: TableCell) -> Self {
        TableCellDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            row: entity.row,
            column: entity.column,
            row_span: entity.row_span,
            column_span: entity.column_span,
            cell_frame: entity.cell_frame,
            fmt_padding: entity.fmt_padding,
            fmt_border: entity.fmt_border,
            fmt_vertical_alignment: entity.fmt_vertical_alignment,
            fmt_background_color: entity.fmt_background_color,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct CreateTableCellDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub row: i64,
    pub column: i64,
    pub row_span: i64,
    pub column_span: i64,
    pub cell_frame: Option<EntityId>,
    pub fmt_padding: Option<i64>,
    pub fmt_border: Option<i64>,
    pub fmt_vertical_alignment: Option<CellVerticalAlignment>,
    pub fmt_background_color: Option<String>,
}

impl From<CreateTableCellDto> for TableCell {
    fn from(dto: CreateTableCellDto) -> Self {
        TableCell {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            row: dto.row,
            column: dto.column,
            row_span: dto.row_span,
            column_span: dto.column_span,
            cell_frame: dto.cell_frame,
            fmt_padding: dto.fmt_padding,
            fmt_border: dto.fmt_border,
            fmt_vertical_alignment: dto.fmt_vertical_alignment,
            fmt_background_color: dto.fmt_background_color,
        }
    }
}

impl From<&CreateTableCellDto> for TableCell {
    fn from(dto: &CreateTableCellDto) -> Self {
        TableCell {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            row: dto.row,
            column: dto.column,
            row_span: dto.row_span,
            column_span: dto.column_span,
            cell_frame: dto.cell_frame,
            fmt_padding: dto.fmt_padding,
            fmt_border: dto.fmt_border,
            fmt_vertical_alignment: dto.fmt_vertical_alignment.clone(),
            fmt_background_color: dto.fmt_background_color.clone(),
        }
    }
}

impl From<TableCell> for CreateTableCellDto {
    fn from(entity: TableCell) -> Self {
        CreateTableCellDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            row: entity.row,
            column: entity.column,
            row_span: entity.row_span,
            column_span: entity.column_span,
            cell_frame: entity.cell_frame,
            fmt_padding: entity.fmt_padding,
            fmt_border: entity.fmt_border,
            fmt_vertical_alignment: entity.fmt_vertical_alignment,
            fmt_background_color: entity.fmt_background_color,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct UpdateTableCellDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub row: i64,
    pub column: i64,
    pub row_span: i64,
    pub column_span: i64,
    pub fmt_padding: Option<i64>,
    pub fmt_border: Option<i64>,
    pub fmt_vertical_alignment: Option<CellVerticalAlignment>,
    pub fmt_background_color: Option<String>,
}

impl From<UpdateTableCellDto> for TableCell {
    fn from(dto: UpdateTableCellDto) -> Self {
        TableCell {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            row: dto.row,
            column: dto.column,
            row_span: dto.row_span,
            column_span: dto.column_span,
            fmt_padding: dto.fmt_padding,
            fmt_border: dto.fmt_border,
            fmt_vertical_alignment: dto.fmt_vertical_alignment,
            fmt_background_color: dto.fmt_background_color,
            cell_frame: Default::default(),
        }
    }
}

impl From<&UpdateTableCellDto> for TableCell {
    fn from(dto: &UpdateTableCellDto) -> Self {
        TableCell {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            row: dto.row,
            column: dto.column,
            row_span: dto.row_span,
            column_span: dto.column_span,
            fmt_padding: dto.fmt_padding,
            fmt_border: dto.fmt_border,
            fmt_vertical_alignment: dto.fmt_vertical_alignment.clone(),
            fmt_background_color: dto.fmt_background_color.clone(),
            cell_frame: Default::default(),
        }
    }
}

impl From<TableCell> for UpdateTableCellDto {
    fn from(entity: TableCell) -> Self {
        UpdateTableCellDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            row: entity.row,
            column: entity.column,
            row_span: entity.row_span,
            column_span: entity.column_span,
            fmt_padding: entity.fmt_padding,
            fmt_border: entity.fmt_border,
            fmt_vertical_alignment: entity.fmt_vertical_alignment,
            fmt_background_color: entity.fmt_background_color,
        }
    }
}

impl From<TableCellDto> for UpdateTableCellDto {
    fn from(dto: TableCellDto) -> Self {
        UpdateTableCellDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            row: dto.row,
            column: dto.column,
            row_span: dto.row_span,
            column_span: dto.column_span,
            fmt_padding: dto.fmt_padding,
            fmt_border: dto.fmt_border,
            fmt_vertical_alignment: dto.fmt_vertical_alignment,
            fmt_background_color: dto.fmt_background_color,
        }
    }
}
pub use common::direct_access::table_cell::TableCellRelationshipField;

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