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

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

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

impl From<FeatureDto> for Feature {
    fn from(dto: FeatureDto) -> Self {
        Feature {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            use_cases: dto.use_cases,
        }
    }
}

impl From<&FeatureDto> for Feature {
    fn from(dto: &FeatureDto) -> Self {
        Feature {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name.clone(),
            use_cases: dto.use_cases.clone(),
        }
    }
}

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

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

impl From<CreateFeatureDto> for Feature {
    fn from(dto: CreateFeatureDto) -> Self {
        Feature {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            use_cases: dto.use_cases,
        }
    }
}

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

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

impl From<UpdateFeatureDto> for Feature {
    fn from(dto: UpdateFeatureDto) -> Self {
        Feature {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
            use_cases: Default::default(),
        }
    }
}

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

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

impl From<FeatureDto> for UpdateFeatureDto {
    fn from(dto: FeatureDto) -> Self {
        UpdateFeatureDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            name: dto.name,
        }
    }
}
pub use common::direct_access::feature::FeatureRelationshipField;

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