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

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

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct RootDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub workspace: Option<EntityId>,
    pub system: Option<EntityId>,
}

impl From<RootDto> for Root {
    fn from(dto: RootDto) -> Self {
        Root {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            workspace: dto.workspace,
            system: dto.system,
        }
    }
}

impl From<&RootDto> for Root {
    fn from(dto: &RootDto) -> Self {
        Root {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            workspace: dto.workspace,
            system: dto.system,
        }
    }
}

impl From<Root> for RootDto {
    fn from(entity: Root) -> Self {
        RootDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            workspace: entity.workspace,
            system: entity.system,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct CreateRootDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub workspace: Option<EntityId>,
    pub system: Option<EntityId>,
}

impl From<CreateRootDto> for Root {
    fn from(dto: CreateRootDto) -> Self {
        Root {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            workspace: dto.workspace,
            system: dto.system,
        }
    }
}

impl From<&CreateRootDto> for Root {
    fn from(dto: &CreateRootDto) -> Self {
        Root {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            workspace: dto.workspace,
            system: dto.system,
        }
    }
}

impl From<Root> for CreateRootDto {
    fn from(entity: Root) -> Self {
        CreateRootDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            workspace: entity.workspace,
            system: entity.system,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct UpdateRootDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
}

impl From<UpdateRootDto> for Root {
    fn from(dto: UpdateRootDto) -> Self {
        Root {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            workspace: Default::default(),
            system: Default::default(),
        }
    }
}

impl From<&UpdateRootDto> for Root {
    fn from(dto: &UpdateRootDto) -> Self {
        Root {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            workspace: Default::default(),
            system: Default::default(),
        }
    }
}

impl From<Root> for UpdateRootDto {
    fn from(entity: Root) -> Self {
        UpdateRootDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
        }
    }
}

impl From<RootDto> for UpdateRootDto {
    fn from(dto: RootDto) -> Self {
        UpdateRootDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
        }
    }
}
pub use common::direct_access::root::RootRelationshipField;

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