修改一版

This commit is contained in:
he
2022-05-13 18:12:50 +08:00
parent 894424a00e
commit 6741f11b27
8 changed files with 85 additions and 50 deletions
@@ -23,10 +23,14 @@ namespace IRaCIS.Core.Application.Services
{
private readonly IRepository<SystemDocument> _systemDocumentRepository;
private readonly IRepository<SystemDocNeedConfirmedUserType> _systemDocNeedConfirmedUserTypeRepository;
public SystemDocumentService( IRepository<SystemDocument> systemDocumentRepository)
public SystemDocumentService( IRepository<SystemDocument> systemDocumentRepository,
IRepository<SystemDocNeedConfirmedUserType> systemDocNeedConfirmedUserTypeRepository
)
{
_systemDocumentRepository = systemDocumentRepository;
this._systemDocNeedConfirmedUserTypeRepository = systemDocNeedConfirmedUserTypeRepository;
}
@@ -66,18 +70,20 @@ namespace IRaCIS.Core.Application.Services
}
else
{
var document = await _systemDocumentRepository.Where(t => t.Id == addOrEditSystemDocument.Id, true,true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync();
var document = await _systemDocumentRepository.Where(t => t.Id == addOrEditSystemDocument.Id, true, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync();
if (document == null) return Null404NotFound(document);
if (await _systemDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditSystemDocument.FileTypeId && t.Name == addOrEditSystemDocument.Name && t.Id != addOrEditSystemDocument.Id,true))
if (await _systemDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditSystemDocument.FileTypeId && t.Name == addOrEditSystemDocument.Name && t.Id != addOrEditSystemDocument.Id, true))
{
return ResponseOutput.NotOk("同类型已存在该文件名");
}
_mapper.Map(addOrEditSystemDocument, document);
document.UpdateTime = DateTime.Now;
if (document.FileTypeId != addOrEditSystemDocument.FileTypeId)
{
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
@@ -94,7 +100,7 @@ namespace IRaCIS.Core.Application.Services
}
}
var success = _repository.SaveChangesAsync();
var success = await _repository.SaveChangesAsync();
return ResponseOutput.Ok(document.Id.ToString());
}
@@ -574,11 +574,11 @@ namespace IRaCIS.Core.Application.Services
{
if (isSystemDoc)
{
await _repository.BatchUpdateAsync<SystemDocument>(t => t.Id == documentId, u => new SystemDocument() { IsDeleted = true });
await _systemDocumentRepository.UpdatePartialFromQueryAsync(documentId, u => new SystemDocument() { IsDeleted = true });
}
else
{
await _trialDocumentRepository.BatchUpdateNoTrackingAsync(t => t.Id == documentId, u => new TrialDocument() { IsDeleted = true });
await _trialDocumentRepository.UpdatePartialFromQueryAsync(documentId, u => new TrialDocument() { IsDeleted = true });
}
return ResponseOutput.Ok();
}