use anyhow::{Result, anyhow};
use crate::Thumbnail;
pub struct ThumbnailDomainService;
impl ThumbnailDomainService {
pub fn new() -> Self {
Self
}
pub fn validate(&self, entity: &Thumbnail) -> Result<()> {
if entity.storage_key.is_empty() {
return Err(anyhow!("storage_key is required"));
}
if entity.storage_backend.is_empty() {
return Err(anyhow!("storage_backend is required"));
}
if entity.mime_type.is_empty() {
return Err(anyhow!("mime_type is required"));
}
if entity.format.is_empty() {
return Err(anyhow!("format is required"));
}
Ok(())
}
pub fn can_create(&self, entity: &Thumbnail) -> Result<bool> {
self.validate(entity)?;
Ok(true)
}
pub fn can_update(&self, _current: &Thumbnail, _updated: &Thumbnail) -> Result<bool> {
Ok(true)
}
pub fn can_delete(&self, _entity: &Thumbnail) -> Result<bool> {
Ok(true)
}
}
impl Default for ThumbnailDomainService {
fn default() -> Self {
Self::new()
}
}