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

use common::entities::File;
pub use common::entities::FileNature;
pub use common::entities::FileStatus;
use common::types::EntityId;
use serde::{Deserialize, Serialize};
use std::convert::From;

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct FileDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub relative_path: String,
    pub group: String,
    pub template_name: String,
    pub generated_code: Option<String>,
    pub status: FileStatus,
    pub nature: FileNature,
    pub feature: Option<EntityId>,
    pub all_features: bool,
    pub entity: Option<EntityId>,
    pub all_entities: bool,
    pub use_case: Option<EntityId>,
    pub all_use_cases: bool,
    pub field: Option<EntityId>,
}

impl From<FileDto> for File {
    fn from(dto: FileDto) -> Self {
        File {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            relative_path: dto.relative_path,
            group: dto.group,
            template_name: dto.template_name,
            generated_code: dto.generated_code,
            status: dto.status,
            nature: dto.nature,
            feature: dto.feature,
            all_features: dto.all_features,
            entity: dto.entity,
            all_entities: dto.all_entities,
            use_case: dto.use_case,
            all_use_cases: dto.all_use_cases,
            field: dto.field,
        }
    }
}

impl From<&FileDto> for File {
    fn from(dto: &FileDto) -> Self {
        File {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            relative_path: dto.relative_path.clone(),
            group: dto.group.clone(),
            template_name: dto.template_name.clone(),
            generated_code: dto.generated_code.clone(),
            status: dto.status.clone(),
            nature: dto.nature.clone(),
            feature: dto.feature,
            all_features: dto.all_features,
            entity: dto.entity,
            all_entities: dto.all_entities,
            use_case: dto.use_case,
            all_use_cases: dto.all_use_cases,
            field: dto.field,
        }
    }
}

impl From<File> for FileDto {
    fn from(entity: File) -> Self {
        FileDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            relative_path: entity.relative_path,
            group: entity.group,
            template_name: entity.template_name,
            generated_code: entity.generated_code,
            status: entity.status,
            nature: entity.nature,
            feature: entity.feature,
            all_features: entity.all_features,
            entity: entity.entity,
            all_entities: entity.all_entities,
            use_case: entity.use_case,
            all_use_cases: entity.all_use_cases,
            field: entity.field,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct CreateFileDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub relative_path: String,
    pub group: String,
    pub template_name: String,
    pub generated_code: Option<String>,
    pub status: FileStatus,
    pub nature: FileNature,
    pub feature: Option<EntityId>,
    pub all_features: bool,
    pub entity: Option<EntityId>,
    pub all_entities: bool,
    pub use_case: Option<EntityId>,
    pub all_use_cases: bool,
    pub field: Option<EntityId>,
}

impl From<CreateFileDto> for File {
    fn from(dto: CreateFileDto) -> Self {
        File {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            relative_path: dto.relative_path,
            group: dto.group,
            template_name: dto.template_name,
            generated_code: dto.generated_code,
            status: dto.status,
            nature: dto.nature,
            feature: dto.feature,
            all_features: dto.all_features,
            entity: dto.entity,
            all_entities: dto.all_entities,
            use_case: dto.use_case,
            all_use_cases: dto.all_use_cases,
            field: dto.field,
        }
    }
}

impl From<&CreateFileDto> for File {
    fn from(dto: &CreateFileDto) -> Self {
        File {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            relative_path: dto.relative_path.clone(),
            group: dto.group.clone(),
            template_name: dto.template_name.clone(),
            generated_code: dto.generated_code.clone(),
            status: dto.status.clone(),
            nature: dto.nature.clone(),
            feature: dto.feature,
            all_features: dto.all_features,
            entity: dto.entity,
            all_entities: dto.all_entities,
            use_case: dto.use_case,
            all_use_cases: dto.all_use_cases,
            field: dto.field,
        }
    }
}

impl From<File> for CreateFileDto {
    fn from(entity: File) -> Self {
        CreateFileDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            relative_path: entity.relative_path,
            group: entity.group,
            template_name: entity.template_name,
            generated_code: entity.generated_code,
            status: entity.status,
            nature: entity.nature,
            feature: entity.feature,
            all_features: entity.all_features,
            entity: entity.entity,
            all_entities: entity.all_entities,
            use_case: entity.use_case,
            all_use_cases: entity.all_use_cases,
            field: entity.field,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct UpdateFileDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub relative_path: String,
    pub group: String,
    pub template_name: String,
    pub generated_code: Option<String>,
    pub status: FileStatus,
    pub nature: FileNature,
    pub all_features: bool,
    pub all_entities: bool,
    pub all_use_cases: bool,
}

impl From<UpdateFileDto> for File {
    fn from(dto: UpdateFileDto) -> Self {
        File {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            relative_path: dto.relative_path,
            group: dto.group,
            template_name: dto.template_name,
            generated_code: dto.generated_code,
            status: dto.status,
            nature: dto.nature,
            all_features: dto.all_features,
            all_entities: dto.all_entities,
            all_use_cases: dto.all_use_cases,
            feature: Default::default(),
            entity: Default::default(),
            use_case: Default::default(),
            field: Default::default(),
        }
    }
}

impl From<&UpdateFileDto> for File {
    fn from(dto: &UpdateFileDto) -> Self {
        File {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            relative_path: dto.relative_path.clone(),
            group: dto.group.clone(),
            template_name: dto.template_name.clone(),
            generated_code: dto.generated_code.clone(),
            status: dto.status.clone(),
            nature: dto.nature.clone(),
            all_features: dto.all_features,
            all_entities: dto.all_entities,
            all_use_cases: dto.all_use_cases,
            feature: Default::default(),
            entity: Default::default(),
            use_case: Default::default(),
            field: Default::default(),
        }
    }
}

impl From<File> for UpdateFileDto {
    fn from(entity: File) -> Self {
        UpdateFileDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            relative_path: entity.relative_path,
            group: entity.group,
            template_name: entity.template_name,
            generated_code: entity.generated_code,
            status: entity.status,
            nature: entity.nature,
            all_features: entity.all_features,
            all_entities: entity.all_entities,
            all_use_cases: entity.all_use_cases,
        }
    }
}

impl From<FileDto> for UpdateFileDto {
    fn from(dto: FileDto) -> Self {
        UpdateFileDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            relative_path: dto.relative_path,
            group: dto.group,
            template_name: dto.template_name,
            generated_code: dto.generated_code,
            status: dto.status,
            nature: dto.nature,
            all_features: dto.all_features,
            all_entities: dto.all_entities,
            all_use_cases: dto.all_use_cases,
        }
    }
}
pub use common::direct_access::file::FileRelationshipField;

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