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

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

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct DtoDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub fields: Vec<EntityId>,
}

impl From<DtoDto> for Dto {
    fn from(dto: DtoDto) -> Self {
        Dto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            fields: dto.fields,
        }
    }
}

impl From<&DtoDto> for Dto {
    fn from(dto: &DtoDto) -> Self {
        Dto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            fields: dto.fields.clone(),
        }
    }
}

impl From<Dto> for DtoDto {
    fn from(entity: Dto) -> Self {
        DtoDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            fields: entity.fields,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct CreateDtoDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub fields: Vec<EntityId>,
}

impl From<CreateDtoDto> for Dto {
    fn from(dto: CreateDtoDto) -> Self {
        Dto {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            fields: dto.fields,
        }
    }
}

impl From<&CreateDtoDto> for Dto {
    fn from(dto: &CreateDtoDto) -> Self {
        Dto {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            fields: dto.fields.clone(),
        }
    }
}

impl From<Dto> for CreateDtoDto {
    fn from(entity: Dto) -> Self {
        CreateDtoDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            fields: entity.fields,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct UpdateDtoDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
}

impl From<UpdateDtoDto> for Dto {
    fn from(dto: UpdateDtoDto) -> Self {
        Dto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            fields: Default::default(),
        }
    }
}

impl From<&UpdateDtoDto> for Dto {
    fn from(dto: &UpdateDtoDto) -> Self {
        Dto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            fields: Default::default(),
        }
    }
}

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

impl From<DtoDto> for UpdateDtoDto {
    fn from(dto: DtoDto) -> Self {
        UpdateDtoDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
        }
    }
}
pub use common::direct_access::dto::DtoRelationshipField;

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