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

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

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

impl From<SystemDto> for System {
    fn from(dto: SystemDto) -> Self {
        System {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            version: dto.version,
            files: dto.files,
        }
    }
}

impl From<&SystemDto> for System {
    fn from(dto: &SystemDto) -> Self {
        System {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            version: dto.version.clone(),
            files: dto.files.clone(),
        }
    }
}

impl From<System> for SystemDto {
    fn from(entity: System) -> Self {
        SystemDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            version: entity.version,
            files: entity.files,
        }
    }
}

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

impl From<CreateSystemDto> for System {
    fn from(dto: CreateSystemDto) -> Self {
        System {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            version: dto.version,
            files: dto.files,
        }
    }
}

impl From<&CreateSystemDto> for System {
    fn from(dto: &CreateSystemDto) -> Self {
        System {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            version: dto.version.clone(),
            files: dto.files.clone(),
        }
    }
}

impl From<System> for CreateSystemDto {
    fn from(entity: System) -> Self {
        CreateSystemDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            version: entity.version,
            files: entity.files,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct UpdateSystemDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub version: String,
}

impl From<UpdateSystemDto> for System {
    fn from(dto: UpdateSystemDto) -> Self {
        System {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            version: dto.version,
            files: Default::default(),
        }
    }
}

impl From<&UpdateSystemDto> for System {
    fn from(dto: &UpdateSystemDto) -> Self {
        System {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            version: dto.version.clone(),
            files: Default::default(),
        }
    }
}

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

impl From<SystemDto> for UpdateSystemDto {
    fn from(dto: SystemDto) -> Self {
        UpdateSystemDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            version: dto.version,
        }
    }
}
pub use common::direct_access::system::SystemRelationshipField;

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