修改
This commit is contained in:
@@ -38,7 +38,7 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||
.ProjectTo<AuditDocumentView>(_mapper.ConfigurationProvider);
|
||||
var pageList= await auditDocumentQueryable.ToPagedListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
return pageList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -47,11 +47,14 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<AuditDocument> UpdateAuditDocument(AuditDocumentUpdateDto inDto)
|
||||
public async Task<IResponseOutput> UpdateAuditDocument(AuditDocumentUpdateDto inDto)
|
||||
{
|
||||
AuditDocumentAddOrEdit addOrEdit = _mapper.Map<AuditDocumentAddOrEdit>(inDto);
|
||||
addOrEdit.IsUpdate = true;
|
||||
return await AddOrUpdateAuditDocument(addOrEdit);
|
||||
|
||||
var result= await AddOrUpdateAuditDocument(addOrEdit);
|
||||
|
||||
return ResponseOutput.Ok(result.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -259,48 +262,53 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> MovieFileOrFolder(MovieFileOrFolderInDto inDto)
|
||||
{
|
||||
var file = await _auditDocumentRepository.Where(x => x.Id == inDto.Id).FirstNotNullAsync();
|
||||
if (file.AuditDocumentTypeEnum == AuditDocumentType.Folder)
|
||||
foreach (var id in inDto.Ids)
|
||||
{
|
||||
var data = await _auditDocumentRepository.Select(x => new DeleteAudit()
|
||||
var file = await _auditDocumentRepository.Where(x => x.Id == id).FirstNotNullAsync();
|
||||
if (file.AuditDocumentTypeEnum == AuditDocumentType.Folder)
|
||||
{
|
||||
Id = x.Id,
|
||||
ParentId = x.ParentId,
|
||||
MainFileId = x.MainFileId
|
||||
}).ToListAsync();
|
||||
if (finChild(new List<Guid> { inDto.Id }, inDto.ParentId, data))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotMove"]);
|
||||
}
|
||||
var data = await _auditDocumentRepository.Select(x => new DeleteAudit()
|
||||
{
|
||||
Id = x.Id,
|
||||
ParentId = x.ParentId,
|
||||
MainFileId = x.MainFileId
|
||||
}).ToListAsync();
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
if (finChild(new List<Guid> { id }, inDto.ParentId, data))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotMove"]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
await _auditDocumentRepository.UpdatePartialFromQueryAsync(id, x => new AuditDocument()
|
||||
{
|
||||
ParentId = inDto.ParentId
|
||||
});
|
||||
|
||||
await _auditDocumentRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await _auditDocumentRepository.UpdatePartialFromQueryAsync(inDto.Id, x => new AuditDocument()
|
||||
{
|
||||
ParentId = inDto.ParentId
|
||||
});
|
||||
|
||||
await _auditDocumentRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class GetHistoricalVersionOutDto
|
||||
|
||||
public class MovieFileOrFolderInDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public List<Guid> Ids { get; set; }
|
||||
|
||||
public Guid ParentId { get; set; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user