修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
efcda61104
commit
0e1310324d
|
@ -17,6 +17,7 @@ using IRaCIS.Core.Infrastructure;
|
|||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using MassTransit;
|
||||
using NPOI.POIFS.Properties;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
namespace IRaCIS.Core.Application.Service;
|
||||
|
||||
|
||||
|
@ -46,7 +47,53 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> UpdateAuditDocument(AuditDocumentAddOrEdit inDto)
|
||||
public async Task<AuditDocument> UpdateAuditDocument(AuditDocumentUpdateDto inDto)
|
||||
{
|
||||
AuditDocumentAddOrEdit addOrEdit = _mapper.Map<AuditDocumentAddOrEdit>(inDto);
|
||||
addOrEdit.IsUpdate = true;
|
||||
return await AddOrUpdateAuditDocument(addOrEdit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增稽查文档
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> AddAuditDocument(List<AuditDocumentAddOrEdit> inDto)
|
||||
{
|
||||
inDto.ForEach(x => x.IsUpdate = false);
|
||||
await addData(inDto);
|
||||
|
||||
async Task addData(List<AuditDocumentAddOrEdit> data)
|
||||
{
|
||||
foreach(var item in data)
|
||||
{
|
||||
var result= await AddOrUpdateAuditDocument(item);
|
||||
|
||||
item.Children.ForEach(x => {
|
||||
x.ParentId = result.Id;
|
||||
x.IsUpdate = false;
|
||||
|
||||
});
|
||||
|
||||
if (item.Children.Count() > 0)
|
||||
{
|
||||
await addData(item.Children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通用方法
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
private async Task<AuditDocument> AddOrUpdateAuditDocument(AuditDocumentAddOrEdit inDto)
|
||||
{
|
||||
if (inDto.ParentId != null)
|
||||
{
|
||||
|
@ -55,11 +102,20 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
{
|
||||
if (inDto.AuditDocumentTypeEnum == AuditDocumentType.Folder)
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotAddFolder"]);
|
||||
if (inDto.IsUpdate)
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotAddFolder"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return alikeData;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var entityData = await _auditDocumentRepository.UpdateFromDTOAsync(inDto, true);
|
||||
var entityData = await _auditDocumentRepository.InsertOrUpdateAsync(inDto, true);
|
||||
|
||||
var historicalVersionIds = await _auditDocumentRepository.Where(x => x.MainFileId == alikeData.Id).OrderBy(x => x.Version).Select(x => x.Id).ToListAsync();
|
||||
|
||||
|
@ -77,23 +133,51 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
});
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok(entityData.Id.ToString());
|
||||
return entityData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var entity = await _auditDocumentRepository.UpdateFromDTOAsync(inDto, true);
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
var entity = await _auditDocumentRepository.InsertOrUpdateAsync(inDto, true);
|
||||
return entity;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 新增稽查文档
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public async Task<IResponseOutput> InsertAuditDocument()
|
||||
//{
|
||||
|
||||
//}
|
||||
/// <summary>
|
||||
/// 获取面包屑导航
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> GetBreadcrumbData(GetBreadcrumbDataInDto inDto)
|
||||
{
|
||||
List<string> result=new List<string>();
|
||||
|
||||
await findParent(result, inDto.Id);
|
||||
async Task findParent(List<string> datas, Guid id)
|
||||
{
|
||||
var data= await _auditDocumentRepository.Where(x => x.Id == inDto.Id).FirstNotNullAsync();
|
||||
datas.Add(data.Name);
|
||||
if (data.ParentId != null)
|
||||
{
|
||||
await findParent(datas, data.ParentId.Value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
result.Reverse();
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 新增稽查文档
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public async Task<IResponseOutput> InsertAuditDocument()
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -107,10 +191,9 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
|||
var data= await _auditDocumentRepository
|
||||
.Where(x=>x.AuditDocumentTypeEnum!=AuditDocumentType.HistoricalVersion)
|
||||
.WhereIf(inDto.IsAuthorization!=null,x=>x.IsAuthorization==inDto.IsAuthorization).ProjectTo<AuditDocumentData>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
var root= data
|
||||
.WhereIf(inDto.Id!= null, x => x.Id == inDto.Id)
|
||||
.WhereIf(inDto.Id==null,x=>x.ParentId==null).ToList();
|
||||
var root= data
|
||||
.WhereIf(inDto.Ids != null, x => inDto.Ids.Contains(x.Id.Value))
|
||||
.WhereIf(inDto.Ids == null,x=>x.ParentId==null).ToList();
|
||||
|
||||
foreach (var item in root)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,7 @@ public class DeleteAuditDocumentInDto
|
|||
|
||||
public class GetAuditDocumentDataInDto
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public List<Guid>? Ids { get; set; }
|
||||
|
||||
public bool? IsAuthorization { get; set; }
|
||||
}
|
||||
|
@ -81,29 +81,40 @@ public class MovieFileOrFolderInDto
|
|||
public Guid ParentId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class AuditDocumentAddOrEdit
|
||||
public class AuditDocumentUpdateDto
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
|
||||
public AuditDocumentType AuditDocumentTypeEnum { get; set; }
|
||||
|
||||
|
||||
public string FileFormat { get; set; }
|
||||
|
||||
|
||||
public string FilePath { get; set; }
|
||||
|
||||
|
||||
public decimal? FileSize { get; set; }
|
||||
|
||||
|
||||
public bool IsAuthorization { get; set; }
|
||||
|
||||
// public Guid? MainFileId { get; set; }
|
||||
|
||||
|
||||
// public Guid? MainFileId { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
public Guid? ParentId { get; set; }
|
||||
|
||||
//public int? Version { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class GetBreadcrumbDataInDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
|
||||
public class AuditDocumentAddOrEdit: AuditDocumentUpdateDto
|
||||
{
|
||||
|
||||
|
||||
public List<AuditDocumentAddOrEdit> Children { get; set; }=new List<AuditDocumentAddOrEdit>() { };
|
||||
|
||||
public bool IsUpdate { get; set; } = true;
|
||||
}
|
||||
|
||||
public class AuditDocumentQuery:PageInput
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
var userId = Guid.Empty;
|
||||
var isEn_Us = false;
|
||||
CreateMap<AuditDocument, AuditDocumentView>();
|
||||
CreateMap<AuditDocumentUpdateDto, AuditDocumentAddOrEdit>();
|
||||
CreateMap<AuditDocument, AuditDocumentData>();
|
||||
CreateMap<AuditDocument, AuditDocumentAddOrEdit>().ReverseMap();
|
||||
CreateMap<SystemDocument, SystemDocumentView>()
|
||||
|
|
Loading…
Reference in New Issue