feat(api): расширен респонс WorkResponse до WorkWithTnkResponse, добавлена полная иерархия тнк. В Work.GetAll добавлен параметр для загрузки с иерархией.
This commit is contained in:
10
PARR.API/Contracts/V1/Requests/Queries/WorkGetAllQuery.cs
Normal file
10
PARR.API/Contracts/V1/Requests/Queries/WorkGetAllQuery.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||||
|
{
|
||||||
|
public class WorkGetAllQuery
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// С иерархией до процесса
|
||||||
|
/// </summary>
|
||||||
|
public bool AllParents { get; set; } = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,4 +10,9 @@
|
|||||||
|
|
||||||
public Guid ProcessId { get; set; }
|
public Guid ProcessId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SubprocessWithProcessResponse : SubprocessResponse
|
||||||
|
{
|
||||||
|
public ProcessResponse? Process { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,4 +10,9 @@
|
|||||||
|
|
||||||
public Guid SubprocessId { get; set; }
|
public Guid SubprocessId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TnkWithSubprocessResponse : TnkResponse
|
||||||
|
{
|
||||||
|
public SubprocessWithProcessResponse? Subprocess { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,4 +10,9 @@
|
|||||||
|
|
||||||
public Guid TnkId { get; set; }
|
public Guid TnkId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class WorkWithTnkResponse : WorkResponse
|
||||||
|
{
|
||||||
|
public TnkWithSubprocessResponse? Tnk { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,18 +52,31 @@ namespace PARR.API.Controllers.V1
|
|||||||
/// <param name="paginationQuery"></param>
|
/// <param name="paginationQuery"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet(ApiRoutes.Work.GetAll)]
|
[HttpGet(ApiRoutes.Work.GetAll)]
|
||||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery)
|
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] WorkGetAllQuery requestQuery)
|
||||||
{
|
{
|
||||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||||
|
|
||||||
IQueryable<Work> query = workService.Get()
|
IQueryable<Work> query = workService.Get()
|
||||||
.OrderBy(t => t.Name);
|
.OrderBy(t => t.Name);
|
||||||
|
|
||||||
|
if (requestQuery.AllParents)
|
||||||
|
query = query.Include(t => t.Tnk).ThenInclude(s => s.Subprocess).ThenInclude(p => p.Process);
|
||||||
|
|
||||||
var works = await workService.GetPage(query, paginationFilter).ToListAsync();
|
var works = await workService.GetPage(query, paginationFilter).ToListAsync();
|
||||||
|
|
||||||
if (!works.Any())
|
if (!works.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
|
if (requestQuery.AllParents)
|
||||||
|
{
|
||||||
|
//todo: тут бесконечность в маппинге
|
||||||
|
// респонс с иерархией вверх до процесса
|
||||||
|
var allResponse = mapper.Map<List<WorkWithTnkResponse>>(works);
|
||||||
|
var paginationAllResponse = new PagedResponse<WorkWithTnkResponse>(allResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||||
|
|
||||||
|
return Ok(paginationAllResponse);
|
||||||
|
}
|
||||||
|
|
||||||
var workResponse = mapper.Map<List<WorkResponse>>(works);
|
var workResponse = mapper.Map<List<WorkResponse>>(works);
|
||||||
var paginationResponse = new PagedResponse<WorkResponse>(workResponse, true).GetPaginatedProps(paginationFilter, query);
|
var paginationResponse = new PagedResponse<WorkResponse>(workResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,11 @@ namespace PARR.API.MappingProfiles
|
|||||||
.ForMember(d => d.LastRun, o => o.MapFrom(s => s.ApplicationsInWork!.LastRun));
|
.ForMember(d => d.LastRun, o => o.MapFrom(s => s.ApplicationsInWork!.LastRun));
|
||||||
// === Template ===
|
// === Template ===
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
CreateMap<Template, TemplateScheduleEsppIdResponse>();
|
CreateMap<Template, TemplateScheduleEsppIdResponse>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
CreateMap<ApplicationsInWork, TemplateAgentResponse>()
|
CreateMap<ApplicationsInWork, TemplateAgentResponse>()
|
||||||
.ForMember(d => d.IsAgent, o => o.MapFrom(s => s.IsAgent))
|
.ForMember(d => d.IsAgent, o => o.MapFrom(s => s.IsAgent))
|
||||||
.ForMember(d => d.Name, o => o.MapFrom(s => s.AgentName))
|
.ForMember(d => d.Name, o => o.MapFrom(s => s.AgentName))
|
||||||
@@ -50,10 +51,28 @@ namespace PARR.API.MappingProfiles
|
|||||||
CreateMap<DAL.Models.TaskStatus, TaskStatusResponse>();
|
CreateMap<DAL.Models.TaskStatus, TaskStatusResponse>();
|
||||||
|
|
||||||
|
|
||||||
|
#region Tnk
|
||||||
|
|
||||||
CreateMap<Process, ProcessResponse>();
|
CreateMap<Process, ProcessResponse>();
|
||||||
CreateMap<Subprocess, SubprocessResponse>();
|
|
||||||
CreateMap<Tnk, TnkResponse>();
|
CreateMap<Subprocess, SubprocessResponse>()
|
||||||
CreateMap<Work, WorkResponse>();
|
.Include<Subprocess, SubprocessWithProcessResponse>();
|
||||||
|
|
||||||
|
CreateMap<Subprocess, SubprocessWithProcessResponse>();
|
||||||
|
|
||||||
|
|
||||||
|
CreateMap<Tnk, TnkResponse>()
|
||||||
|
.Include<Tnk, TnkWithSubprocessResponse>();
|
||||||
|
|
||||||
|
CreateMap<Tnk, TnkWithSubprocessResponse>();
|
||||||
|
|
||||||
|
|
||||||
|
CreateMap<Work, WorkResponse>()
|
||||||
|
.Include<Work, WorkWithTnkResponse>();
|
||||||
|
|
||||||
|
CreateMap<Work, WorkWithTnkResponse>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
CreateMap<Application, ApplicationResponse>()
|
CreateMap<Application, ApplicationResponse>()
|
||||||
@@ -161,7 +180,7 @@ namespace PARR.API.MappingProfiles
|
|||||||
.ForMember(d => d.RobotStatus, o => o.MapFrom(s => s.RobotStatus));
|
.ForMember(d => d.RobotStatus, o => o.MapFrom(s => s.RobotStatus));
|
||||||
|
|
||||||
|
|
||||||
// --- EsppSch ---
|
#region EsppSch
|
||||||
CreateMap<EsppSchTypeSchedule, EsppScheduleTypeScheduleResponse>();
|
CreateMap<EsppSchTypeSchedule, EsppScheduleTypeScheduleResponse>();
|
||||||
|
|
||||||
CreateMap<EsppSchType, EsppScheduleTypeResponse>();
|
CreateMap<EsppSchType, EsppScheduleTypeResponse>();
|
||||||
@@ -172,7 +191,7 @@ namespace PARR.API.MappingProfiles
|
|||||||
.ForMember(d => d.Order, o => o.MapFrom(s => s.Order))
|
.ForMember(d => d.Order, o => o.MapFrom(s => s.Order))
|
||||||
.ForMember(d => d.Value, o => o.MapFrom(s => s.Value))
|
.ForMember(d => d.Value, o => o.MapFrom(s => s.Value))
|
||||||
.ForMember(d => d.Type, o => o.MapFrom(s => s.Type));
|
.ForMember(d => d.Type, o => o.MapFrom(s => s.Type));
|
||||||
// === EsppSch ===
|
#endregion EsppSch
|
||||||
|
|
||||||
CreateMap<AgentHistoryLevel, AgentHistoryLevelResponse>();
|
CreateMap<AgentHistoryLevel, AgentHistoryLevelResponse>();
|
||||||
|
|
||||||
@@ -211,6 +230,7 @@ namespace PARR.API.MappingProfiles
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region ApplicationInWork
|
||||||
|
|
||||||
CreateMap<ApplicationsInWork, ApplicationInWorkResponse>()
|
CreateMap<ApplicationsInWork, ApplicationInWorkResponse>()
|
||||||
.ForMember(d => d.Work, o => o.MapFrom(s => s.Work))
|
.ForMember(d => d.Work, o => o.MapFrom(s => s.Work))
|
||||||
@@ -218,6 +238,8 @@ namespace PARR.API.MappingProfiles
|
|||||||
.ForMember(d => d.TemplatesCount, o => o.MapFrom(s => s.Templates.Count()))
|
.ForMember(d => d.TemplatesCount, o => o.MapFrom(s => s.Templates.Count()))
|
||||||
.ForMember(d => d.Schedule, o => o.MapFrom<ApplicationInWorkScheduleResolver>());
|
.ForMember(d => d.Schedule, o => o.MapFrom<ApplicationInWorkScheduleResolver>());
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
CreateMap<EkStatus, EkStatusResponse>();
|
CreateMap<EkStatus, EkStatusResponse>();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user