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