From ad8a13b05e6d6895fe91f1eee50b13c939c98ebb Mon Sep 17 00:00:00 2001 From: sunliang <593170460@qq.com> Date: Wed, 10 Apr 2024 17:46:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=B9=E9=87=8F=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E6=96=87=E4=BB=B6=EF=BC=8C=E6=89=B9=E9=87=8F=E5=85=B3?= =?UTF-8?q?=E8=81=94=E5=8F=8A=E5=85=A8=E5=B1=80=E5=92=8C=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MinioController/MinioApiController.cs | 100 +++++++++--------- .../MinioController/GetStoragePathModel.cs | 2 +- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs index 20f9e7d..72bbb6f 100644 --- a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs +++ b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs @@ -346,7 +346,7 @@ namespace IBKLinker_Minio.Controller.MinioController /// /// 文件关联表 [HttpPost, Route("AddFileassociation")] - public RequestEntity AddFileassociation(MinioFileassociation minioFileassociation) + public RequestEntity AddFileassociation(IList minioFileassociation) { RequestEntity request = new RequestEntity(); ///创建数据库连接上下文对象 @@ -354,41 +354,44 @@ namespace IBKLinker_Minio.Controller.MinioController { try { - bool Asstion = true;//定义是否执行关联 - IList SelMFdata = new List(); - SelMFdata = db.Query("select * from MINIO_FILEASSOCIATION where 1=1 and (FILE_PK='" + minioFileassociation.FilePk + "' or ASSOCIATION_FILE_PK='" + minioFileassociation.FilePk + "')"); - //查询当前被关联文件是否已经被关联过 - if (SelMFdata.Count > 0) + foreach (var data in minioFileassociation) { - foreach (var item in SelMFdata) + bool Asstion = true;//定义是否执行关联 + IList SelMFdata = new List(); + SelMFdata = db.Query("select * from MINIO_FILEASSOCIATION where 1=1 and (FILE_PK='" + data.FilePk + "' or ASSOCIATION_FILE_PK='" + data.FilePk + "')"); + //查询当前被关联文件是否已经被关联过 + if (SelMFdata.Count > 0) { - if (item.FilePk == minioFileassociation.FilePk && item.AssociationFilePk == minioFileassociation.AssociationFilePk) //如果当前要关联的pk 等于已有的关联pk 被关联pk 等于已有的被关联pk - { - Asstion = false; - } - if (item.FilePk == minioFileassociation.AssociationFilePk && item.AssociationFilePk == minioFileassociation.FilePk) //如果当前要关联的pk 等于已有的被关联pk 被关联pk 等于已有的关联pk + foreach (var item in SelMFdata) { - Asstion = false; + if (item.FilePk == data.FilePk && item.AssociationFilePk == data.AssociationFilePk) //如果当前要关联的pk 等于已有的关联pk 被关联pk 等于已有的被关联pk + { + Asstion = false; + } + if (item.FilePk == data.AssociationFilePk && item.AssociationFilePk == data.FilePk) //如果当前要关联的pk 等于已有的被关联pk 被关联pk 等于已有的关联pk + { + Asstion = false; + } } } - } - if (Asstion) - { - db.BeginTransaction();//启动事务 - ///拿到表自增长的值赋值给自增长主键pk - minioFileassociation.Pk = Convert.ToInt32(db.QueryScalar("select S_MINIO_FILEASSOCIATION.nextval from dual")); - minioFileassociation.CreatorTime = DateTime.Now; + if (Asstion) + { + db.BeginTransaction();//启动事务 + ///拿到表自增长的值赋值给自增长主键pk + data.Pk = Convert.ToInt32(db.QueryScalar("select S_MINIO_FILEASSOCIATION.nextval from dual")); + data.CreatorTime = DateTime.Now; - ///把需要添加的数据同步到数据库 - db.Insert(minioFileassociation); - db.Commit();//提交事务 - request.code = "0"; - request.msg = "关联成功!"; - } - else - { - request.code = "1"; - request.msg = "当前文件已经被关联过,请勿重复关联!"; + ///把需要添加的数据同步到数据库 + db.Insert(data); + db.Commit();//提交事务 + request.code = "0"; + request.msg = "关联成功!"; + } + else + { + request.code = "1"; + request.msg = "当前文件已经被关联过,请勿重复关联!"; + } } } catch (Exception ex) @@ -972,6 +975,7 @@ namespace IBKLinker_Minio.Controller.MinioController { foreach (var item in data) { + date = new MinioStoragePath(); date.Pk = item.Pk;//主键ID date.Upk = item.Upk;//子文件夹的父ID date.FileName = item.FileName;//文件名称 @@ -1028,22 +1032,22 @@ namespace IBKLinker_Minio.Controller.MinioController datelist.Add(date); } } - if (datelist != null) - { - if (UdpMFdata.Count > 0) - { - db.Update(UdpMFdata); - } - db.Update(datelist); - db.Commit();//提交事务 - request.code = "0"; - request.msg = "修改成功!"; - } - else + } + if (datelist != null) + { + if (UdpMFdata.Count > 0) { - request.code = "1"; - request.msg = "请检查是否符合修改规范!"; + db.Update(UdpMFdata); } + db.Update(datelist); + db.Commit();//提交事务 + request.code = "0"; + request.msg = "修改成功!"; + } + else + { + request.code = "1"; + request.msg = "请检查是否符合修改规范!"; } } catch (Exception ex) @@ -1149,10 +1153,10 @@ namespace IBKLinker_Minio.Controller.MinioController { sql += " and FILE_NAME like'%" + PathData.FileName + "%'"; } - //if (PathData.Upk > 0) //如果在子文件夹内 - //{ - // sql += " and UPK = '" + PathData.Upk + "'"; - //} + if (PathData.Pk > 0) //如果在子文件夹内 + { + sql += " and UPK = '" + PathData.Pk + "'"; + } if (!string.IsNullOrEmpty(PathData.BeginTime))//如果有开始时间 { sql += string.Format(" and CREATE_TIME >= to_date('{0}', 'yyyy/mm/dd hh24:mi:ss')", PathData.BeginTime);//开始时间 diff --git a/IBKLinker-Minio/Entity/MinioController/GetStoragePathModel.cs b/IBKLinker-Minio/Entity/MinioController/GetStoragePathModel.cs index f22f8da..06edc48 100644 --- a/IBKLinker-Minio/Entity/MinioController/GetStoragePathModel.cs +++ b/IBKLinker-Minio/Entity/MinioController/GetStoragePathModel.cs @@ -20,7 +20,7 @@ namespace IBKLinker_Minio.Entity.MinioController /// ///子文件夹的父ID /// - public int Upk { get; set; } + public int Pk { get; set; } /// /// 开始时间