diff --git a/IBKLinker-Minio/Common/MinioBusinessLogic.cs b/IBKLinker-Minio/Common/MinioBusinessLogic.cs index fb86b40..a64022b 100644 --- a/IBKLinker-Minio/Common/MinioBusinessLogic.cs +++ b/IBKLinker-Minio/Common/MinioBusinessLogic.cs @@ -87,5 +87,28 @@ namespace IBKLinker_Minio.Common MOdata.CreationTime = time;//创建时间 db.Insert(MOdata);//写入数据库 } + /// + /// 文件夹递归查询 + /// + public List GetSubDirectories(int parentPk) + { + List subDirs = new List(); + using (IDbContext db = ObjectContainer.GetObject("db")) + { + List subDirectories = db.Query("select * from MINIO_STORAGE_PATH where UPK ='" + parentPk + "' and CLEAR_FLAG='0' and FILE_TYPE='0' ORDER BY PK").ToList();//查询子级中是否还有子级 + foreach (var subDir in subDirectories) + { + RequstStoragePath subDirModel = new RequstStoragePath(); + subDirModel.Pk = subDir.Pk;//主键ID + subDirModel.FileName = subDir.FileName;//文件名称 + subDirModel.FilePath = subDir.FilePath;//文件路径 + subDirModel.FileType = subDir.FileType;//文件类型 + subDirModel.FileLever = subDir.FileLevel;//层级 + subDirModel.requstStoragePaths = GetSubDirectories(subDir.Pk); // 递归调用获取子文件夹 + subDirs.Add(subDirModel); + } + } + return subDirs; + } } } diff --git a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs index d7f6ed1..d468add 100644 --- a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs +++ b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs @@ -359,8 +359,7 @@ namespace IBKLinker_Minio.Controller.MinioController { db.BeginTransaction();//启动事务 ///拿到表自增长的值赋值给自增长主键pk - minioFileassociation.Pk = getPk("S_MINIO_FILEASSOCIATION", "MINIO_FILEASSOCIATION"); - ///给创建时间赋值 + minioFileassociation.Pk = Convert.ToInt32(db.QueryScalar("select S_MINIO_FILEASSOCIATION.nextval from dual")); minioFileassociation.CreatorTime = DateTime.Now; ///把需要添加的数据同步到数据库 @@ -550,8 +549,9 @@ namespace IBKLinker_Minio.Controller.MinioController else { - request.code = "1"; - request.msg = "查询失败!"; + request.code = "0"; + request.msg = "暂无数据!"; + request.data = result; } } @@ -1590,5 +1590,42 @@ namespace IBKLinker_Minio.Controller.MinioController } #endregion + #region + [HttpPost, Route("CESHI")] + public RequestEntity CESHI() + { + MinioBusinessLogic bb = new MinioBusinessLogic();//定义业务逻辑方法 + RequestEntity request = new RequestEntity(); + try + { + List requstStoragePaths = new List(); + using (IDbContext db = ObjectContainer.GetObject("db")) + { + List rootDirectories = db.Query("select * from MINIO_STORAGE_PATH where CLEAR_FLAG='0' and FILE_TYPE='0'and FILE_LEVEL='1' ORDER BY PK").ToList();//查询根文件夹 + foreach (var rootDir in rootDirectories) + { + RequstStoragePath rootModel = new RequstStoragePath(); + rootModel.Pk = rootDir.Pk;//主键ID + rootModel.FileName = rootDir.FileName;//文件名称 + rootModel.FilePath = rootDir.FilePath;//文件路径 + rootModel.FileType = rootDir.FileType;//文件类型 + rootModel.FileLever = rootDir.FileLevel;//层级 + rootModel.requstStoragePaths = bb.GetSubDirectories(rootDir.Pk);//子级存进list + requstStoragePaths.Add(rootModel);//添加list + } + } + request.data = requstStoragePaths; + request.code = "0"; + } + catch (Exception) + { + request.code = "1"; + throw; + } + + return request; + } + #endregion + } }