From ae6a97c9aced860a86db133ce5a92b6218753483 Mon Sep 17 00:00:00 2001 From: dao Date: Wed, 8 May 2024 11:28:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=A0=E9=99=A4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../File/FileFolder/FileFolderService.cs | 53 +++++++++++++++++-- .../File/FileInfo/FileInfoService.cs | 4 +- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileFolder/FileFolderService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileFolder/FileFolderService.cs index 37012d28a..6a93bf7a3 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileFolder/FileFolderService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileFolder/FileFolderService.cs @@ -57,11 +57,56 @@ namespace Learun.Application.OA.File.FileFolder /// 主键 public void RemoveForm(string keyValue) { - FileFolderEntity fileFolderEntity = new FileFolderEntity(); - fileFolderEntity.Modify(keyValue); - fileFolderEntity.F_DeleteMark = 1; - this.BaseRepository().Update(fileFolderEntity); + var db = this.BaseRepository().BeginTrans(); + try + { + var fid = new List(); + fid.Add(keyValue); + var floder = db.FindList(x => x.F_DeleteMark != 1).ToList(); + DelFloderChild(keyValue, fid, floder); + + var fs = floder.Where(x => fid.Contains(x.F_FolderId)).ToList(); + foreach (var f in fs) + { + f.F_DeleteMark = 1; + f.F_ModifyDate = DateTime.Now; + } + db.Update(fs); + + var file=db.FindList(x=>x.F_DeleteMark!=1 && fid.Contains(x.F_FolderId)).ToList(); + if(file.Any()) + { + foreach (var f in file) + { + f.F_DeleteMark = 1; + f.F_ModifyDate = DateTime.Now; + } + + db.Update(file); + } + + db.Commit(); + } + catch (Exception) + { + db.Rollback(); + throw; + } + } + + private void DelFloderChild(string kv,List fid,List floder) + { + var child=floder.Where(x=>x.F_ParentId == kv); + if(child.Any()) + { + foreach (var f in child) + { + fid.Add(f.F_FolderId); + DelFloderChild(f.F_FolderId,fid,floder); + } + } } + /// /// 彻底删除文件夹 /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoService.cs index 0eb33dba8..8f16e7ef4 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/File/FileInfo/FileInfoService.cs @@ -243,7 +243,7 @@ namespace Learun.Application.OA.File.FileInfo 'folder' AS F_FileType , F_CreateUserId, F_ModifyDate - FROM LR_OA_FileFolder where F_DeleteMark = 1 and F_ParentId is null + FROM LR_OA_FileFolder where F_DeleteMark = 1 UNION SELECT F_FileId , F_FolderId , @@ -252,7 +252,7 @@ namespace Learun.Application.OA.File.FileInfo F_FileType , F_CreateUserId, F_ModifyDate - FROM LR_OA_FileInfo where F_DeleteMark = 1 and F_FolderId = '0' + FROM LR_OA_FileInfo where F_DeleteMark = 1 ) t WHERE F_CreateUserId = @userId"); strSql.Append(" ORDER BY F_ModifyDate DESC"); return this.BaseRepository().FindList(strSql.ToString(), new { userId = userId });