feat(api): добавлен фильтр нарядов по templateId. В респонс шаблонов добавлено поле кол-во нарядов.
This commit is contained in:
10
PARR.API/Contracts/V1/Requests/Queries/OrderQuery.cs
Normal file
10
PARR.API/Contracts/V1/Requests/Queries/OrderQuery.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||
{
|
||||
public class OrderQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Поиск по ИД шаблона
|
||||
/// </summary>
|
||||
public Guid? TemplateId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -35,5 +35,7 @@
|
||||
/// Расписание
|
||||
/// </summary>
|
||||
public EsppScheduleResponse? Schedule { get; set; }
|
||||
|
||||
public int OrderCount { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.Constants;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
@@ -39,16 +40,19 @@ namespace PARR.API.Controllers.V1
|
||||
/// <param name="paginationQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.Order.GetAll)]
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery)
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] OrderQuery filter)
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
var query = orderService.Get()
|
||||
IQueryable<Order> query = orderService.Get()
|
||||
.Include(t => t.Template)
|
||||
.Include(s => s.OrderStatus)
|
||||
.Include(s => s.NextStatus)
|
||||
.OrderByDescending(t => t.DateCreated);
|
||||
|
||||
if (filter.TemplateId.HasValue)
|
||||
query = query.Where(t => t.TemplateId == filter.TemplateId.Value);
|
||||
|
||||
var orders = await orderService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
if (!orders.Any())
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace PARR.API.Controllers.V1
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||
.Include(t => t.Orders)
|
||||
.OrderBy(t => t.Name)
|
||||
.AsSplitQuery();
|
||||
|
||||
@@ -90,6 +91,7 @@ namespace PARR.API.Controllers.V1
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||
.Include(t=>t.Orders)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
@@ -114,6 +116,7 @@ namespace PARR.API.Controllers.V1
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||
.Include(t => t.Orders)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
@@ -143,6 +146,7 @@ namespace PARR.API.Controllers.V1
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
|
||||
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
|
||||
.Include(t => t.Orders)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace PARR.API.MappingProfiles
|
||||
.ForMember(d => d.Schedule, o => o.MapFrom<TemplateScheduleResolver>())
|
||||
.ForMember(d => d.Agent, o => o.MapFrom(s => s.ApplicationsInWork))
|
||||
.ForMember(d => d.NextRun, o => o.MapFrom(s => s.ApplicationsInWork!.NextRun))
|
||||
.ForMember(d => d.LastRun, o => o.MapFrom(s => s.ApplicationsInWork!.LastRun));
|
||||
.ForMember(d => d.LastRun, o => o.MapFrom(s => s.ApplicationsInWork!.LastRun))
|
||||
.ForMember(d => d.OrderCount, o => o.MapFrom(s => s.Orders.Count()));
|
||||
// === Template ===
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user