/// <summary> /// 删除数据 /// </summary> /// <param name="folder">数据实体</param> public void Delete(int id) { FolderEntity entity = FolderDA.GetById(id); if (entity == null) { throw new BusinessException("数据不存在无法删除"); } bool hasChildren = this.ListByParentId(entity.Id).Any(); if (hasChildren) { throw new BusinessException(string.Format("{0}目录下存在子目录,不允许删除该目录", entity.Name)); } bool hasDocument = DocumentBasisService.ListByFolderId(entity.Id, null).Any(); if (hasDocument) { throw new BusinessException(string.Format("{0}目录下存在文件,不允许删除该目录", entity.Name)); } FolderDA.Delete(new FolderEntity() { Id = entity.Id, IsDeleted = DeletedEnums.Deleted }); }
/// <summary> /// 根据Id获取目录数据 /// </summary> /// <param name="id">id</param> /// <returns>返回目录数据</returns> public FolderVO GetById(int id) { return(FolderDA.GetById(id).ToFolderVo()); }
/// <summary> /// 检查父节点是否被删除 /// </summary> /// <param name="parentId">父节点id</param> /// <returns>true/false</returns> public bool CheckParentIsDeleted(int parentId) { return(FolderDA.GetById(parentId) == null); }