From 0a697534e47b6ebac774860982ff2adfcbedfb1b Mon Sep 17 00:00:00 2001 From: sunliang <593170460@qq.com> Date: Wed, 22 Nov 2023 17:59:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=B3=E8=81=94=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=85=B3=E8=81=94=E6=96=87=E4=BB=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=85=B3=E8=81=94=E8=A1=A8=E5=AE=9E=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IBKLinker-Minio/Common/MinioBusinessLogic.cs | 2 +- .../MinioController/MinioApiController.cs | 104 +++++++++++++++--- .../MinioController/MinioFileassociation.cs | 6 +- 3 files changed, 90 insertions(+), 22 deletions(-) diff --git a/IBKLinker-Minio/Common/MinioBusinessLogic.cs b/IBKLinker-Minio/Common/MinioBusinessLogic.cs index 51ba4bd..fb86b40 100644 --- a/IBKLinker-Minio/Common/MinioBusinessLogic.cs +++ b/IBKLinker-Minio/Common/MinioBusinessLogic.cs @@ -83,7 +83,7 @@ namespace IBKLinker_Minio.Common MOdata.FilePk = FilePk.ToString();//文件pk MOdata.FileUPk = FileUPk.ToString();//文件父级pk MOdata.FileName = FileName;//文件名 - MOdata.Operater = OperateUser + Operate + FileName + " " + time.ToString();//操作 + MOdata.Operater = OperateUser + Operate + FileName;//操作(操作人,加操作,加文件名称) MOdata.CreationTime = time;//创建时间 db.Insert(MOdata);//写入数据库 } diff --git a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs index d1feb7b..d7f6ed1 100644 --- a/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs +++ b/IBKLinker-Minio/Controller/MinioController/MinioApiController.cs @@ -342,28 +342,39 @@ namespace IBKLinker_Minio.Controller.MinioController public RequestEntity AddFileassociation(MinioFileassociation minioFileassociation) { RequestEntity request = new RequestEntity(); + ///创建数据库连接上下文对象 using (IDbContext db = ObjectContainer.GetObject("db")) { try { - db.BeginTransaction();//启动事务 - ///创建数据库连接上下文对象 - - ///拿到表自增长的值赋值给自增长主键pk - minioFileassociation.Pk = getPk("S_MINIO_FILEASSOCIATION", "MINIO_FILEASSOCIATION"); - ///给创建时间赋值 - minioFileassociation.CreatorTime = DateTime.Now; + IList SelMFdata = new List(); + SelMFdata = db.Query("select * from MINIO_FILEASSOCIATION where 1=1 and FILE_PK='"+ minioFileassociation.FilePk+ "' and ASSOCIATION_FILE_PK='"+ minioFileassociation.AssociationFilePk+ "'"); + //查询当前被关联文件是否已经被关联过 + if (SelMFdata.Count > 0) + { + request.code = "1"; + request.msg = "当前文件已经被关联过,请勿重复关联!"; + } + else + { + db.BeginTransaction();//启动事务 + ///拿到表自增长的值赋值给自增长主键pk + minioFileassociation.Pk = getPk("S_MINIO_FILEASSOCIATION", "MINIO_FILEASSOCIATION"); + ///给创建时间赋值 + minioFileassociation.CreatorTime = DateTime.Now; - ///把需要添加的数据同步到数据库 - db.Insert(minioFileassociation); - db.Commit();//提交事务 - request.code = "0"; - request.msg = "关联成功!"; + ///把需要添加的数据同步到数据库 + db.Insert(minioFileassociation); + db.Commit();//提交事务 + request.code = "0"; + request.msg = "关联成功!"; + } } catch (Exception ex) { db.Rollback();//回滚 request.code = "1"; + request.msg = "关联失败!"; logger.ErrorFormat("主表:MINIO_FILEASSOCIATION,minio文件关联表表添加数据失败,错误原因:{0}", ex); } } @@ -483,11 +494,66 @@ namespace IBKLinker_Minio.Controller.MinioController } } //通过文件类型判断是查文件的下一级还是查文件的上下级 + IList SelMFdata = new List(); + IList result = new List(); + SelMFdata = db.Query("select * from MINIO_FILEASSOCIATION where 1=1 " + sql + " ORDER BY PK"); + if (SelMFdata.Count > 0) //如果有数据 + { + foreach (var item in SelMFdata) + { + MinioFileassociation date = new MinioFileassociation();//存储单条数据 + if (item.FilePk.ToString() == FilePk)//判断当前查询结果文件pk是否等于选中的文件pk + { + #region 数据赋值 + date.Pk = item.Pk;//主键 + date.FileType = item.FileType;//文件类型 + date.FilePk = item.FilePk;//文件PK + date.FilePath = item.FilePath;//文件路径 + date.FileLevel = item.FileLevel;//文件层级 + date.FileName = item.FileName;//文件名称 + date.DownloadNum = item.DownloadNum;//文件下载次数 + date.CreatorUser = item.CreatorUser;//创建者 + date.CreatorTime = item.CreatorTime;//创建时间 + date.AssociationFilePk = item.AssociationFilePk;//关联文件PK + date.AssociationFileType = item.AssociationFileType;//关联文件类型 + date.AssorciationFilePath = item.AssorciationFilePath;//关联文件路径 + date.AssociationFileName = item.AssociationFileName;//关联文件名称 + date.AssociationFileLevel = item.AssociationFileLevel;//关联文件层级 + date.AssociationDownloadNum = item.AssociationDownloadNum;//关联文件下载次数 + #endregion + } + else //如果不等与的话将关联文件与被关联文件信息调换位置返回前端 + { + #region 数据赋值 + date.Pk = item.Pk;//主键 + date.FileType = item.AssociationFileType;//文件类型 + date.FilePk = item.AssociationFilePk;//文件PK + date.FilePath = item.AssorciationFilePath;//文件路径 + date.FileLevel = item.AssociationFileLevel;//文件层级 + date.FileName = item.AssociationFileName;//文件名称 + date.DownloadNum = item.AssociationDownloadNum;//文件下载次数 + date.CreatorUser = item.CreatorUser;//创建者 + date.CreatorTime = item.CreatorTime;//创建时间 + date.AssociationFilePk = item.FilePk;//关联文件PK + date.AssociationFileType = item.FileType;//关联文件类型 + date.AssorciationFilePath = item.FilePath;//关联文件路径 + date.AssociationFileName = item.FileName;//关联文件名称 + date.AssociationFileLevel = item.FileLevel;//关联文件层级 + date.AssociationDownloadNum = item.DownloadNum;//关联文件下载次数 + #endregion + } + result.Add(date);//添加数据到list + } + request.data = result; + request.code = "0"; + } + else + { + request.code = "1"; + request.msg = "查询失败!"; + } - IList result = new List(); - request.data = db.Query("select * from MINIO_FILEASSOCIATION where 1=1 " + sql + " ORDER BY PK"); - request.code = "0"; } } } @@ -1082,8 +1148,8 @@ namespace IBKLinker_Minio.Controller.MinioController { string sql = string.Empty; - date = db.Query("select * from MINIO_STORAGE_PATH where UPK=0 AND FILE_LEVEL=1 and CLEAR_FLAG='0' ORDER BY PK").ToList(); - + date = db.Query("select * from MINIO_STORAGE_PATH where CLEAR_FLAG='0'and FILE_TYPE='0' ORDER BY PK").ToList(); + //UPK=0 AND FILE_LEVEL=1 and } if (date.Count > 0) { @@ -1204,6 +1270,9 @@ namespace IBKLinker_Minio.Controller.MinioController #endregion #region minio文件下载及预览 + /// + /// 件下载及预览接口 + /// [HttpPost, Route("FileDownload")] public RequestEntity FileDownload(List minioStoragePath) { @@ -1252,7 +1321,6 @@ namespace IBKLinker_Minio.Controller.MinioController request.msg = "请联系管理员检查!"; request.code = "1"; } - } catch (Exception ex) { diff --git a/IBKLinker-Minio/Entity/MinioController/MinioFileassociation.cs b/IBKLinker-Minio/Entity/MinioController/MinioFileassociation.cs index c28e7fe..cce8399 100644 --- a/IBKLinker-Minio/Entity/MinioController/MinioFileassociation.cs +++ b/IBKLinker-Minio/Entity/MinioController/MinioFileassociation.cs @@ -80,14 +80,14 @@ namespace IBKLinker_Minio.Entity.MinioController /// ///关联文件类型 /// - [Persistent("ASSOCIATION_FILE_TYPE"), DisplayName("文件类型")] + [Persistent("ASSOCIATION_FILE_TYPE"), DisplayName("关联文件类型")] public string AssociationFileType { get; set; } /// ///关联文件下载次数 /// - [Persistent("ASSOCIATION_DOWNLOAD_NUM"), DisplayName("文件下载次数")] + [Persistent("ASSOCIATION_DOWNLOAD_NUM"), DisplayName("关联文件下载次数")] public string AssociationDownloadNum { get; set; } @@ -95,7 +95,7 @@ namespace IBKLinker_Minio.Entity.MinioController /// ///关联文件层级 /// - [Persistent("ASSOCIATION_FILE_LEVEL"), DisplayName("文件层级")] + [Persistent("ASSOCIATION_FILE_LEVEL"), DisplayName("关联文件层级")] public string AssociationFileLevel { get; set; } ///