修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f781027388
commit
71e797cf7d
|
@ -262,17 +262,21 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
[HttpPost]
|
||||
public async Task<IResponseOutput> MovieFileOrFolder(MovieFileOrFolderInDto inDto)
|
||||
{
|
||||
|
||||
var data = await _auditDocumentRepository.Select(x => new DeleteAudit()
|
||||
{
|
||||
Id = x.Id,
|
||||
ParentId = x.ParentId,
|
||||
AuditDocumentTypeEnum = x.AuditDocumentTypeEnum,
|
||||
MainFileId = x.MainFileId
|
||||
}).ToListAsync();
|
||||
|
||||
foreach (var id in inDto.Ids)
|
||||
{
|
||||
var file = await _auditDocumentRepository.Where(x => x.Id == id).FirstNotNullAsync();
|
||||
var file = data.Where(x => x.Id == id).FirstOrDefault();
|
||||
if (file.AuditDocumentTypeEnum == AuditDocumentType.Folder)
|
||||
{
|
||||
var data = await _auditDocumentRepository.Select(x => new DeleteAudit()
|
||||
{
|
||||
Id = x.Id,
|
||||
ParentId = x.ParentId,
|
||||
MainFileId = x.MainFileId
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
if (finChild(new List<Guid> { id }, inDto.ParentId, data))
|
||||
{
|
||||
|
@ -280,26 +284,33 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool finChild(List<Guid> ids, Guid ChildId, List<DeleteAudit> data)
|
||||
bool finChild(List<Guid> ids, Guid ChildId, List<DeleteAudit> data)
|
||||
{
|
||||
var child = data.Where(x => x.ParentId != null && ids.Contains(x.ParentId.Value)).ToList();
|
||||
if (child.Count() == 0)
|
||||
{
|
||||
var child = data.Where(x => x.ParentId != null && ids.Contains(x.ParentId.Value)).ToList();
|
||||
if (child.Count() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (child.Any(x => x.Id == ChildId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var newids = child.Select(x => x.Id).ToList();
|
||||
|
||||
return finChild(newids, ChildId, data);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (child.Any(x => x.Id == ChildId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var newids = child.Select(x => x.Id).ToList();
|
||||
|
||||
return finChild(newids, ChildId, data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var id in inDto.Ids)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
await _auditDocumentRepository.UpdatePartialFromQueryAsync(id, x => new AuditDocument()
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@ public class DeleteAudit
|
|||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public AuditDocumentType AuditDocumentTypeEnum { get; set; }
|
||||
public Guid? ParentId { get; set; }
|
||||
|
||||
public Guid? MainFileId { get; set; }
|
||||
|
|
Loading…
Reference in New Issue