修改
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 DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using NPOI.POIFS.Properties;
|
using NPOI.POIFS.Properties;
|
||||||
|
using Org.BouncyCastle.Crypto;
|
||||||
namespace IRaCIS.Core.Application.Service;
|
namespace IRaCIS.Core.Application.Service;
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +47,53 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||||
/// <param name="inDto"></param>
|
/// <param name="inDto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[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)
|
if (inDto.ParentId != null)
|
||||||
{
|
{
|
||||||
|
@ -54,12 +101,21 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||||
if (alikeData != null)
|
if (alikeData != null)
|
||||||
{
|
{
|
||||||
if (inDto.AuditDocumentTypeEnum == AuditDocumentType.Folder)
|
if (inDto.AuditDocumentTypeEnum == AuditDocumentType.Folder)
|
||||||
|
{
|
||||||
|
if (inDto.IsUpdate)
|
||||||
{
|
{
|
||||||
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotAddFolder"]);
|
throw new BusinessValidationFailedException(_localizer["AuditDocument_CanNotAddFolder"]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var entityData = await _auditDocumentRepository.UpdateFromDTOAsync(inDto, true);
|
return alikeData;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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();
|
var historicalVersionIds = await _auditDocumentRepository.Where(x => x.MainFileId == alikeData.Id).OrderBy(x => x.Version).Select(x => x.Id).ToListAsync();
|
||||||
|
|
||||||
|
@ -77,15 +133,43 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseOutput.Ok(entityData.Id.ToString());
|
return entityData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var entity = await _auditDocumentRepository.UpdateFromDTOAsync(inDto, true);
|
var entity = await _auditDocumentRepository.InsertOrUpdateAsync(inDto, true);
|
||||||
return ResponseOutput.Ok(entity.Id.ToString());
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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>
|
||||||
///// 新增稽查文档
|
///// 新增稽查文档
|
||||||
///// </summary>
|
///// </summary>
|
||||||
|
@ -107,10 +191,9 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||||
var data= await _auditDocumentRepository
|
var data= await _auditDocumentRepository
|
||||||
.Where(x=>x.AuditDocumentTypeEnum!=AuditDocumentType.HistoricalVersion)
|
.Where(x=>x.AuditDocumentTypeEnum!=AuditDocumentType.HistoricalVersion)
|
||||||
.WhereIf(inDto.IsAuthorization!=null,x=>x.IsAuthorization==inDto.IsAuthorization).ProjectTo<AuditDocumentData>(_mapper.ConfigurationProvider).ToListAsync();
|
.WhereIf(inDto.IsAuthorization!=null,x=>x.IsAuthorization==inDto.IsAuthorization).ProjectTo<AuditDocumentData>(_mapper.ConfigurationProvider).ToListAsync();
|
||||||
|
|
||||||
var root= data
|
var root= data
|
||||||
.WhereIf(inDto.Id!= null, x => x.Id == inDto.Id)
|
.WhereIf(inDto.Ids != null, x => inDto.Ids.Contains(x.Id.Value))
|
||||||
.WhereIf(inDto.Id==null,x=>x.ParentId==null).ToList();
|
.WhereIf(inDto.Ids == null,x=>x.ParentId==null).ToList();
|
||||||
|
|
||||||
foreach (var item in root)
|
foreach (var item in root)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class DeleteAuditDocumentInDto
|
||||||
|
|
||||||
public class GetAuditDocumentDataInDto
|
public class GetAuditDocumentDataInDto
|
||||||
{
|
{
|
||||||
public Guid? Id { get; set; }
|
public List<Guid>? Ids { get; set; }
|
||||||
|
|
||||||
public bool? IsAuthorization { get; set; }
|
public bool? IsAuthorization { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,7 @@ public class MovieFileOrFolderInDto
|
||||||
public Guid ParentId { get; set; }
|
public Guid ParentId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AuditDocumentUpdateDto
|
||||||
public class AuditDocumentAddOrEdit
|
|
||||||
{
|
{
|
||||||
public Guid? Id { get; set; }
|
public Guid? Id { get; set; }
|
||||||
|
|
||||||
|
@ -101,9 +100,21 @@ public class AuditDocumentAddOrEdit
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public Guid? ParentId { 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
|
public class AuditDocumentQuery:PageInput
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
var userId = Guid.Empty;
|
var userId = Guid.Empty;
|
||||||
var isEn_Us = false;
|
var isEn_Us = false;
|
||||||
CreateMap<AuditDocument, AuditDocumentView>();
|
CreateMap<AuditDocument, AuditDocumentView>();
|
||||||
|
CreateMap<AuditDocumentUpdateDto, AuditDocumentAddOrEdit>();
|
||||||
CreateMap<AuditDocument, AuditDocumentData>();
|
CreateMap<AuditDocument, AuditDocumentData>();
|
||||||
CreateMap<AuditDocument, AuditDocumentAddOrEdit>().ReverseMap();
|
CreateMap<AuditDocument, AuditDocumentAddOrEdit>().ReverseMap();
|
||||||
CreateMap<SystemDocument, SystemDocumentView>()
|
CreateMap<SystemDocument, SystemDocumentView>()
|
||||||
|
|
Loading…
Reference in New Issue