v3.4.6
This commit is contained in:
@@ -84,6 +84,12 @@ public class DocumentService : IDynamicApiController, ITransient
|
||||
.WhereIF(input.keyword.IsNotEmptyOrNull(), t => t.FullName.Contains(input.keyword))
|
||||
.OrderBy(x => x.SortCode).OrderBy(x => x.CreatorTime, OrderByType.Desc)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.keyword), t => t.LastModifyTime, OrderByType.Desc).ToListAsync()).Adapt<List<DocumentListOutput>>();
|
||||
string[]? typeList = new string[] { "doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf", "jpg", "jpeg", "gif", "png", "bmp" };
|
||||
foreach (var item in data)
|
||||
{
|
||||
string? type = item.fullName.Split('.').LastOrDefault();
|
||||
item.isPreview = typeList.Contains(type) ? "1" : null;
|
||||
}
|
||||
return new { list = data };
|
||||
}
|
||||
|
||||
@@ -248,6 +254,7 @@ public class DocumentService : IDynamicApiController, ITransient
|
||||
entity.FilePath = Path.Combine(_filePath, input.file.FileName);
|
||||
entity.FileSize = input.file.Length.ToString();
|
||||
entity.DeleteMark = 0;
|
||||
entity.UploaderUrl = string.Format("/api/file/Image/document/{0}", entity.FilePath);
|
||||
var isOk = await _repository.AsSugarClient().Insertable(entity).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
|
||||
if (isOk < 1)
|
||||
throw Oops.Oh(ErrorCode.D8001);
|
||||
@@ -261,11 +268,12 @@ public class DocumentService : IDynamicApiController, ITransient
|
||||
[HttpPost("merge")]
|
||||
public async Task<dynamic> merge([FromForm] ChunkModel input)
|
||||
{
|
||||
if (await _repository.IsAnyAsync(x => x.FullName == input.fileName && x.Type == 1 && x.DeleteMark != 1))
|
||||
if (await _repository.IsAnyAsync(x =>x.CreatorUserId==_userManager.UserId && x.FullName == input.fileName && x.Type == 1 && x.DeleteMark != 1))
|
||||
{
|
||||
string directoryPath = Path.Combine(App.GetConfig<AppOptions>("JNPF_App", true).SystemPath, "TemporaryFile", input.identifier);
|
||||
FileHelper.DeleteDirectory(directoryPath);
|
||||
throw Oops.Oh(ErrorCode.D8002);
|
||||
//string directoryPath = Path.Combine(App.GetConfig<AppOptions>("JNPF_App", true).SystemPath, "TemporaryFile", input.identifier);
|
||||
//FileHelper.DeleteDirectory(directoryPath);
|
||||
//throw Oops.Oh(ErrorCode.D8002);
|
||||
input.fileName = string.Format("{0}-{1}", DateTime.Now.ParseToUnixTime(), input.fileName);
|
||||
}
|
||||
input.isUpdateName = false;
|
||||
input.type = "document";
|
||||
@@ -276,10 +284,11 @@ public class DocumentService : IDynamicApiController, ITransient
|
||||
entity.Type = 1;
|
||||
entity.FullName = input.fileName;
|
||||
entity.ParentId = input.parentId;
|
||||
entity.FileExtension = Path.GetExtension(input.fileName).Replace(".", string.Empty);
|
||||
entity.FileExtension = input.extension;
|
||||
entity.FilePath = output.name;
|
||||
entity.FileSize = input.fileSize;
|
||||
entity.DeleteMark = 0;
|
||||
entity.UploaderUrl = string.Format("/api/file/Image/document/{0}", entity.FilePath);
|
||||
var isOk = await _repository.AsSugarClient().Insertable(entity).CallEntityMethod(m => m.Creator()).ExecuteCommandAsync();
|
||||
if (isOk < 1)
|
||||
throw Oops.Oh(ErrorCode.D8001);
|
||||
@@ -299,8 +308,7 @@ public class DocumentService : IDynamicApiController, ITransient
|
||||
throw Oops.Oh(ErrorCode.D8000);
|
||||
var fileName = _userManager.UserId + "|" + entity.FilePath + "|document";
|
||||
_cacheManager.Set(entity.FilePath, string.Empty);
|
||||
return new
|
||||
{
|
||||
return new {
|
||||
name = entity.FullName,
|
||||
url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "JNPF")
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user