backend/model/dto/
plants_impl.rsuse crate::model::{entity::Plants, r#enum::life_cycle::LifeCycle};
use super::PlantsSummaryDto;
impl From<Plants> for PlantsSummaryDto {
fn from(plants: Plants) -> Self {
let life_cycle: Vec<LifeCycle> = plants
.life_cycle
.map_or(vec![], |v| v.into_iter().flatten().collect());
Self {
id: plants.id,
unique_name: plants.unique_name,
common_name_en: plants.common_name_en,
common_name_de: plants.common_name_de,
spread: plants.spread,
life_cycle,
}
}
}
impl<T> From<(T, Plants)> for PlantsSummaryDto {
fn from((_, plants): (T, Plants)) -> Self {
Self::from(plants)
}
}