use uuid::Uuid;
use crate::{
config::data::SharedPool,
error::ServiceError,
model::dto::base_layer_images::{BaseLayerImageDto, UpdateBaseLayerImageDto},
model::entity::base_layer_images::BaseLayerImages,
};
pub async fn find(
pool: &SharedPool,
layer_id: Uuid,
) -> Result<Vec<BaseLayerImageDto>, ServiceError> {
let mut conn = pool.get().await?;
let result = BaseLayerImages::find(&mut conn, layer_id).await?;
Ok(result)
}
pub async fn create(
dto: BaseLayerImageDto,
pool: &SharedPool,
) -> Result<BaseLayerImageDto, ServiceError> {
let mut conn = pool.get().await?;
let result = BaseLayerImages::create(dto, &mut conn).await?;
Ok(result)
}
pub async fn update(
id: Uuid,
dto: UpdateBaseLayerImageDto,
pool: &SharedPool,
) -> Result<BaseLayerImageDto, ServiceError> {
let mut conn = pool.get().await?;
let result = BaseLayerImages::update(id, dto, &mut conn).await?;
Ok(result)
}
pub async fn delete_by_id(id: Uuid, pool: &SharedPool) -> Result<(), ServiceError> {
let mut conn = pool.get().await?;
let _ = BaseLayerImages::delete_by_id(id, &mut conn).await?;
Ok(())
}