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

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

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct ResourceDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub resource_type: ResourceType,
    pub name: String,
    pub url: String,
    pub mime_type: String,
    pub data_base64: String,
}

impl From<ResourceDto> for Resource {
    fn from(dto: ResourceDto) -> Self {
        Resource {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            resource_type: dto.resource_type,
            name: dto.name,
            url: dto.url,
            mime_type: dto.mime_type,
            data_base64: dto.data_base64,
        }
    }
}

impl From<&ResourceDto> for Resource {
    fn from(dto: &ResourceDto) -> Self {
        Resource {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            resource_type: dto.resource_type.clone(),
            name: dto.name.clone(),
            url: dto.url.clone(),
            mime_type: dto.mime_type.clone(),
            data_base64: dto.data_base64.clone(),
        }
    }
}

impl From<Resource> for ResourceDto {
    fn from(entity: Resource) -> Self {
        ResourceDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            resource_type: entity.resource_type,
            name: entity.name,
            url: entity.url,
            mime_type: entity.mime_type,
            data_base64: entity.data_base64,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct CreateResourceDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub resource_type: ResourceType,
    pub name: String,
    pub url: String,
    pub mime_type: String,
    pub data_base64: String,
}

impl From<CreateResourceDto> for Resource {
    fn from(dto: CreateResourceDto) -> Self {
        Resource {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            resource_type: dto.resource_type,
            name: dto.name,
            url: dto.url,
            mime_type: dto.mime_type,
            data_base64: dto.data_base64,
        }
    }
}

impl From<&CreateResourceDto> for Resource {
    fn from(dto: &CreateResourceDto) -> Self {
        Resource {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            resource_type: dto.resource_type.clone(),
            name: dto.name.clone(),
            url: dto.url.clone(),
            mime_type: dto.mime_type.clone(),
            data_base64: dto.data_base64.clone(),
        }
    }
}

impl From<Resource> for CreateResourceDto {
    fn from(entity: Resource) -> Self {
        CreateResourceDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            resource_type: entity.resource_type,
            name: entity.name,
            url: entity.url,
            mime_type: entity.mime_type,
            data_base64: entity.data_base64,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct UpdateResourceDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub resource_type: ResourceType,
    pub name: String,
    pub url: String,
    pub mime_type: String,
    pub data_base64: String,
}

impl From<UpdateResourceDto> for Resource {
    fn from(dto: UpdateResourceDto) -> Self {
        Resource {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            resource_type: dto.resource_type,
            name: dto.name,
            url: dto.url,
            mime_type: dto.mime_type,
            data_base64: dto.data_base64,
        }
    }
}

impl From<&UpdateResourceDto> for Resource {
    fn from(dto: &UpdateResourceDto) -> Self {
        Resource {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            resource_type: dto.resource_type.clone(),
            name: dto.name.clone(),
            url: dto.url.clone(),
            mime_type: dto.mime_type.clone(),
            data_base64: dto.data_base64.clone(),
        }
    }
}

impl From<Resource> for UpdateResourceDto {
    fn from(entity: Resource) -> Self {
        UpdateResourceDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            resource_type: entity.resource_type,
            name: entity.name,
            url: entity.url,
            mime_type: entity.mime_type,
            data_base64: entity.data_base64,
        }
    }
}

impl From<ResourceDto> for UpdateResourceDto {
    fn from(dto: ResourceDto) -> Self {
        UpdateResourceDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            resource_type: dto.resource_type,
            name: dto.name,
            url: dto.url,
            mime_type: dto.mime_type,
            data_base64: dto.data_base64,
        }
    }
}
