查询修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
977adf3153
commit
12c8c641ea
|
@ -26,20 +26,20 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService
|
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
///// <summary>
|
||||||
/// 获取稽查文档
|
///// 获取稽查文档
|
||||||
/// </summary>
|
///// </summary>
|
||||||
/// <param name="inQuery"></param>
|
///// <param name="inQuery"></param>
|
||||||
/// <returns></returns>
|
///// <returns></returns>
|
||||||
[HttpPost]
|
//[HttpPost]
|
||||||
public async Task<PageOutput<AuditDocumentView>> GetAuditDocumentList(AuditDocumentQuery inQuery)
|
//public async Task<PageOutput<AuditDocumentView>> GetAuditDocumentList(AuditDocumentQuery inQuery)
|
||||||
{
|
//{
|
||||||
var auditDocumentQueryable =_auditDocumentRepository
|
// var auditDocumentQueryable =_auditDocumentRepository
|
||||||
.ProjectTo<AuditDocumentView>(_mapper.ConfigurationProvider);
|
// .ProjectTo<AuditDocumentView>(_mapper.ConfigurationProvider);
|
||||||
var pageList= await auditDocumentQueryable.ToPagedListAsync(inQuery);
|
// var pageList= await auditDocumentQueryable.ToPagedListAsync(inQuery);
|
||||||
|
|
||||||
return pageList;
|
// return pageList;
|
||||||
}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修改稽查文档
|
/// 修改稽查文档
|
||||||
|
@ -190,26 +190,60 @@ public class AuditDocumentService(IRepository<AuditDocument> _auditDocumentRepos
|
||||||
/// <param name="inDto"></param>
|
/// <param name="inDto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<GetAuditDocumentDataOutDto> GetAuditDocumentData(GetAuditDocumentDataInDto inDto)
|
public async Task<PageOutput<AuditDocumentData>> GetAuditDocumentData(GetAuditDocumentDataInDto inDto)
|
||||||
{
|
{
|
||||||
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
|
|
||||||
.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)
|
|
||||||
|
|
||||||
|
if (inDto.Name.IsNotNullOrEmpty())
|
||||||
|
{
|
||||||
|
List<Guid> findIds = new List<Guid>();
|
||||||
|
var findData = data.Where(x => x.Name.Contains(inDto.Name)).Select(x => x.Id.Value).ToList();
|
||||||
|
GetParentId(findIds, findData, data);
|
||||||
|
findIds.AddRange(findData);
|
||||||
|
|
||||||
|
data = data.Where(x => findIds.Contains(x.Id.Value)).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var query = data
|
||||||
|
.WhereIf(inDto.Id != null, x => inDto.Id == x.ParentId)
|
||||||
|
.WhereIf(inDto.Id == null, x => x.ParentId == null);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PageOutput<AuditDocumentData> result = new PageOutput<AuditDocumentData>()
|
||||||
|
{
|
||||||
|
PageIndex = inDto.PageIndex,
|
||||||
|
PageSize = inDto.PageSize,
|
||||||
|
TotalCount = query.Count(),
|
||||||
|
};
|
||||||
|
|
||||||
|
var root = query
|
||||||
|
.OrderBy(x => x.Name)
|
||||||
|
.Skip(inDto.PageSize * (inDto.PageIndex - 1)).Take(inDto.PageSize).ToList();
|
||||||
|
|
||||||
|
foreach (var item in root)
|
||||||
{
|
{
|
||||||
GetChildren(item, data);
|
GetChildren(item, data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
result.CurrentPageData = root;
|
||||||
|
return result;
|
||||||
|
|
||||||
return new GetAuditDocumentDataOutDto()
|
}
|
||||||
{
|
|
||||||
Data = root
|
|
||||||
};
|
|
||||||
|
|
||||||
|
public void GetParentId(List<Guid> parentIds, List<Guid> ids, List<AuditDocumentData> dataList)
|
||||||
|
{
|
||||||
|
var parentid = dataList.Where(x => ids.Contains(x.Id.Value) && x.ParentId != null).Select(x => x.ParentId.Value).ToList();
|
||||||
|
|
||||||
|
parentIds.AddRange(parentid);
|
||||||
|
|
||||||
|
GetParentId(parentIds, parentid, dataList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetChildren(AuditDocumentData item, List<AuditDocumentData> dataList)
|
private void GetChildren(AuditDocumentData item, List<AuditDocumentData> dataList)
|
||||||
|
|
|
@ -24,11 +24,13 @@ public class DeleteAuditDocumentInDto
|
||||||
public List<Guid> Ids { get; set; }
|
public List<Guid> Ids { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetAuditDocumentDataInDto
|
public class GetAuditDocumentDataInDto:PageInput
|
||||||
{
|
{
|
||||||
public List<Guid>? Ids { get; set; }
|
public Guid? Id { get; set; }
|
||||||
|
|
||||||
public bool? IsAuthorization { get; set; }
|
public bool? IsAuthorization { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetAuditDocumentDataOutDto
|
public class GetAuditDocumentDataOutDto
|
||||||
|
|
Loading…
Reference in New Issue