修改关联文件查询接口,修改关联文件添加接口,修改文件关联表实体类

master
孙亮 12 months ago
parent ae1c60aa4a
commit 0a697534e4

@ -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<MinioOperationlog>(MOdata);//写入数据库
}

@ -342,28 +342,39 @@ namespace IBKLinker_Minio.Controller.MinioController
public RequestEntity AddFileassociation(MinioFileassociation minioFileassociation)
{
RequestEntity request = new RequestEntity();
///创建数据库连接上下文对象
using (IDbContext db = ObjectContainer.GetObject<IDbContext>("db"))
{
try
{
db.BeginTransaction();//启动事务
///创建数据库连接上下文对象
///拿到表自增长的值赋值给自增长主键pk
minioFileassociation.Pk = getPk("S_MINIO_FILEASSOCIATION", "MINIO_FILEASSOCIATION");
///给创建时间赋值
minioFileassociation.CreatorTime = DateTime.Now;
IList<MinioFileassociation> SelMFdata = new List<MinioFileassociation>();
SelMFdata = db.Query<MinioFileassociation>("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>(minioFileassociation);
db.Commit();//提交事务
request.code = "0";
request.msg = "关联成功!";
///把需要添加的数据同步到数据库
db.Insert<MinioFileassociation>(minioFileassociation);
db.Commit();//提交事务
request.code = "0";
request.msg = "关联成功!";
}
}
catch (Exception ex)
{
db.Rollback();//回滚
request.code = "1";
request.msg = "关联失败!";
logger.ErrorFormat("主表:MINIO_FILEASSOCIATIONminio文件关联表表添加数据失败错误原因:{0}", ex);
}
}
@ -483,11 +494,66 @@ namespace IBKLinker_Minio.Controller.MinioController
}
}
//通过文件类型判断是查文件的下一级还是查文件的上下级
IList<MinioFileassociation> SelMFdata = new List<MinioFileassociation>();
IList<MinioFileassociation> result = new List<MinioFileassociation>();
SelMFdata = db.Query<MinioFileassociation>("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<MinioFileassociation> result = new List<MinioFileassociation>();
request.data = db.Query<MinioFileassociation>("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<MinioStoragePath>("select * from MINIO_STORAGE_PATH where UPK=0 AND FILE_LEVEL=1 and CLEAR_FLAG='0' ORDER BY PK").ToList();
date = db.Query<MinioStoragePath>("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文件下载及预览
/// <summary>
/// 件下载及预览接口
/// </summary>
[HttpPost, Route("FileDownload")]
public RequestEntity FileDownload(List<MinioStoragePath> minioStoragePath)
{
@ -1252,7 +1321,6 @@ namespace IBKLinker_Minio.Controller.MinioController
request.msg = "请联系管理员检查!";
request.code = "1";
}
}
catch (Exception ex)
{

@ -80,14 +80,14 @@ namespace IBKLinker_Minio.Entity.MinioController
/// <summary>
///关联文件类型
/// </summary>
[Persistent("ASSOCIATION_FILE_TYPE"), DisplayName("文件类型")]
[Persistent("ASSOCIATION_FILE_TYPE"), DisplayName("关联文件类型")]
public string AssociationFileType { get; set; }
/// <summary>
///关联文件下载次数
/// </summary>
[Persistent("ASSOCIATION_DOWNLOAD_NUM"), DisplayName("文件下载次数")]
[Persistent("ASSOCIATION_DOWNLOAD_NUM"), DisplayName("关联文件下载次数")]
public string AssociationDownloadNum { get; set; }
@ -95,7 +95,7 @@ namespace IBKLinker_Minio.Entity.MinioController
/// <summary>
///关联文件层级
/// </summary>
[Persistent("ASSOCIATION_FILE_LEVEL"), DisplayName("文件层级")]
[Persistent("ASSOCIATION_FILE_LEVEL"), DisplayName("关联文件层级")]
public string AssociationFileLevel { get; set; }
/// <summary>

Loading…
Cancel
Save