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

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

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct DtoFieldDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub field_type: DtoFieldType,
    pub optional: bool,
    pub is_list: bool,
    pub enum_name: Option<String>,
    pub enum_values: Vec<String>,
}

impl From<DtoFieldDto> for DtoField {
    fn from(dto: DtoFieldDto) -> Self {
        DtoField {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            field_type: dto.field_type,
            optional: dto.optional,
            is_list: dto.is_list,
            enum_name: dto.enum_name,
            enum_values: dto.enum_values,
        }
    }
}

impl From<&DtoFieldDto> for DtoField {
    fn from(dto: &DtoFieldDto) -> Self {
        DtoField {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            field_type: dto.field_type.clone(),
            optional: dto.optional,
            is_list: dto.is_list,
            enum_name: dto.enum_name.clone(),
            enum_values: dto.enum_values.clone(),
        }
    }
}

impl From<DtoField> for DtoFieldDto {
    fn from(entity: DtoField) -> Self {
        DtoFieldDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            field_type: entity.field_type,
            optional: entity.optional,
            is_list: entity.is_list,
            enum_name: entity.enum_name,
            enum_values: entity.enum_values,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct CreateDtoFieldDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub field_type: DtoFieldType,
    pub optional: bool,
    pub is_list: bool,
    pub enum_name: Option<String>,
    pub enum_values: Vec<String>,
}

impl From<CreateDtoFieldDto> for DtoField {
    fn from(dto: CreateDtoFieldDto) -> Self {
        DtoField {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            field_type: dto.field_type,
            optional: dto.optional,
            is_list: dto.is_list,
            enum_name: dto.enum_name,
            enum_values: dto.enum_values,
        }
    }
}

impl From<&CreateDtoFieldDto> for DtoField {
    fn from(dto: &CreateDtoFieldDto) -> Self {
        DtoField {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            field_type: dto.field_type.clone(),
            optional: dto.optional,
            is_list: dto.is_list,
            enum_name: dto.enum_name.clone(),
            enum_values: dto.enum_values.clone(),
        }
    }
}

impl From<DtoField> for CreateDtoFieldDto {
    fn from(entity: DtoField) -> Self {
        CreateDtoFieldDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            field_type: entity.field_type,
            optional: entity.optional,
            is_list: entity.is_list,
            enum_name: entity.enum_name,
            enum_values: entity.enum_values,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct UpdateDtoFieldDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub name: String,
    pub field_type: DtoFieldType,
    pub optional: bool,
    pub is_list: bool,
    pub enum_name: Option<String>,
    pub enum_values: Vec<String>,
}

impl From<UpdateDtoFieldDto> for DtoField {
    fn from(dto: UpdateDtoFieldDto) -> Self {
        DtoField {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            field_type: dto.field_type,
            optional: dto.optional,
            is_list: dto.is_list,
            enum_name: dto.enum_name,
            enum_values: dto.enum_values,
        }
    }
}

impl From<&UpdateDtoFieldDto> for DtoField {
    fn from(dto: &UpdateDtoFieldDto) -> Self {
        DtoField {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            field_type: dto.field_type.clone(),
            optional: dto.optional,
            is_list: dto.is_list,
            enum_name: dto.enum_name.clone(),
            enum_values: dto.enum_values.clone(),
        }
    }
}

impl From<DtoField> for UpdateDtoFieldDto {
    fn from(entity: DtoField) -> Self {
        UpdateDtoFieldDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            name: entity.name,
            field_type: entity.field_type,
            optional: entity.optional,
            is_list: entity.is_list,
            enum_name: entity.enum_name,
            enum_values: entity.enum_values,
        }
    }
}

impl From<DtoFieldDto> for UpdateDtoFieldDto {
    fn from(dto: DtoFieldDto) -> Self {
        UpdateDtoFieldDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            field_type: dto.field_type,
            optional: dto.optional,
            is_list: dto.is_list,
            enum_name: dto.enum_name,
            enum_values: dto.enum_values,
        }
    }
}
