增加测试递归文件夹

master
孙亮 10 months ago
parent 0a697534e4
commit 627a77fdfb

@ -87,5 +87,28 @@ namespace IBKLinker_Minio.Common
MOdata.CreationTime = time;//创建时间
db.Insert<MinioOperationlog>(MOdata);//写入数据库
}
/// <summary>
/// 文件夹递归查询
/// </summary>
public List<StoragePath> GetSubDirectories(int parentPk)
{
List<StoragePath> subDirs = new List<StoragePath>();
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
List<MinioStoragePath> subDirectories = db.Query<MinioStoragePath>("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;
}
}
}

@ -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<RequstStoragePath> requstStoragePaths = new List<RequstStoragePath>();
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
List<MinioStoragePath> rootDirectories = db.Query<MinioStoragePath>("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
}
}

Loading…
Cancel
Save