feat(api): в work getAll добавлен фильр по имени. ApplicationController GetAll + filter

This commit is contained in:
Mikhail Trubnikov
2024-04-03 15:21:47 +10:00
parent a92bbf1899
commit 693acc4cbc
5 changed files with 108 additions and 5 deletions

View File

@@ -52,22 +52,26 @@ namespace PARR.API.Controllers.V1
/// <param name="paginationQuery"></param>
/// <returns></returns>
[HttpGet(ApiRoutes.Work.GetAll)]
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] WorkGetAllQuery requestQuery)
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] WorkGetAllQuery filter)
{
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
IQueryable<Work> query = workService.Get()
.OrderBy(t => t.Name);
if (requestQuery.AllParents)
if (filter.AllParents)
query = query.Include(t => t.Tnk).ThenInclude(s => s.Subprocess).ThenInclude(p => p.Process);
if (!string.IsNullOrWhiteSpace(filter.Name))
query = query.Where(t => t.Name.ToLower().Contains(filter.Name.ToLower()));
var works = await workService.GetPage(query, paginationFilter).ToListAsync();
if (!works.Any())
return NoContent();
if (requestQuery.AllParents)
if (filter.AllParents)
{
//todo: тут бесконечность в маппинге
// респонс с иерархией вверх до процесса