feat(api): в AgentHistoryResponse добавлена информация о шаблоне
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
|
||||
public Guid TemplateId { get; set; }
|
||||
|
||||
public string? TemplateName { get; set; }
|
||||
|
||||
public AgentHistoryLevelResponse? Level { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ namespace PARR.API.Controllers.V1
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
IQueryable<AgentHistory> query = agentHistoryService.Get()
|
||||
.Include(t => t.AgentHistoryLevel);
|
||||
.Include(t => t.AgentHistoryLevel)
|
||||
.Include(t => t.Template);
|
||||
|
||||
if (request.TemplateId.HasValue)
|
||||
query = query.Where(t => t.TemplateId == request.TemplateId);
|
||||
@@ -88,7 +89,10 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpGet(ApiRoutes.AgentHistory.Get)]
|
||||
public async Task<IActionResult> GetById([FromRoute] Guid id)
|
||||
{
|
||||
var history = await agentHistoryService.Get().Include(t => t.AgentHistoryLevel).FirstAsync(t => t.Id == id);
|
||||
var history = await agentHistoryService.Get()
|
||||
.Include(t => t.AgentHistoryLevel)
|
||||
.Include(t => t.Template)
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
|
||||
if (history == null)
|
||||
return NotFound();
|
||||
@@ -137,7 +141,7 @@ namespace PARR.API.Controllers.V1
|
||||
if (!await agentHistoryService.CreateAsync(agentJournal) || !await agentHistoryService.CommitAsync())
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при добавлении записи в историю работы агента." } }));
|
||||
|
||||
var createdObject = await agentHistoryService.Get().Include(t => t.AgentHistoryLevel).FirstAsync(t => t.Id == agentJournal.Id);
|
||||
var createdObject = await agentHistoryService.Get().Include(t => t.AgentHistoryLevel).Include(t => t.Template).FirstAsync(t => t.Id == agentJournal.Id);
|
||||
var response = mapper.Map<AgentHistoryResponse>(createdObject);
|
||||
|
||||
var createdUri = uriService.GetUri(ApiRoutes.AgentHistory.Get, ApiRoutes.AgentHistory.getParam, agentJournal.Id);
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace PARR.API.MappingProfiles
|
||||
{
|
||||
public DomainToResponseProfile()
|
||||
{
|
||||
#region Template
|
||||
|
||||
// --- Template ---
|
||||
CreateMap<Template, TemplateResponse>()
|
||||
.ForMember(d => d.Work, o => o.MapFrom(s => s.ApplicationsInWork!.Work))
|
||||
@@ -33,6 +35,8 @@ namespace PARR.API.MappingProfiles
|
||||
.ForMember(d => d.LastRun, o => o.MapFrom(s => s.ApplicationsInWork!.LastRun));
|
||||
// === Template ===
|
||||
|
||||
#endregion
|
||||
|
||||
CreateMap<Template, TemplateScheduleEsppIdResponse>();
|
||||
|
||||
CreateMap<ApplicationsInWork, TemplateAgentResponse>()
|
||||
@@ -55,6 +59,8 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
CreateMap<ApplicationType, ApplicationTypeResponse>();
|
||||
|
||||
#region Host
|
||||
|
||||
// --- Host ---
|
||||
CreateMap<DAL.Models.Host, HostBaseResponse>()
|
||||
.Include<DAL.Models.Host, HostTemplateResponse>()
|
||||
@@ -68,6 +74,8 @@ namespace PARR.API.MappingProfiles
|
||||
.ForMember(d => d.Applications, o => o.MapFrom(s => s.ApplicationsInHosts.Select(t => t.Application).OrderBy(t => t.Name)));
|
||||
// === Host ===
|
||||
|
||||
#endregion
|
||||
|
||||
CreateMap<RobotStatus, RobotStatusResponse>();
|
||||
|
||||
CreateMap<RobotHistoryLevel, RobotHistoryLevelResponse>();
|
||||
@@ -81,6 +89,7 @@ namespace PARR.API.MappingProfiles
|
||||
.ForMember(d => d.TemplateName, o => o.MapFrom(s => s.RobotConfiguration!.Template!.Name));
|
||||
|
||||
|
||||
#region RobotConfiguration
|
||||
// --- RobotConfiguration ---
|
||||
CreateMap<RobotConfiguration, RobotTaskBaseResponse>()
|
||||
.Include<RobotConfiguration, RobotTaskTemplateResponse>()
|
||||
@@ -132,6 +141,7 @@ namespace PARR.API.MappingProfiles
|
||||
s.Template!.ApplicationsInWork!.EsppSchValues!.First()!.EsppSchTypeConfig!.EsppSchTypeSchedule!.Id))
|
||||
.ForMember(d => d.Schedule, o => o.MapFrom<RobotTaskScheduleSchResolver>());
|
||||
// === RobotConfiguration ===
|
||||
#endregion
|
||||
|
||||
CreateMap<Robot, RobotResponse>();
|
||||
|
||||
@@ -160,7 +170,8 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
CreateMap<AgentHistory, AgentHistoryResponse>()
|
||||
.ForMember(t => t.Date, o => o.MapFrom(s => s.DateCreated))
|
||||
.ForMember(t => t.Level, o => o.MapFrom(s => s.AgentHistoryLevel));
|
||||
.ForMember(t => t.Level, o => o.MapFrom(s => s.AgentHistoryLevel))
|
||||
.ForMember(t => t.TemplateName, o => o.MapFrom(s => s.Template!.Name));
|
||||
|
||||
|
||||
|
||||
@@ -176,7 +187,9 @@ namespace PARR.API.MappingProfiles
|
||||
#endregion
|
||||
|
||||
#region Order
|
||||
|
||||
CreateMap<OrderStatus, OrderStatusResponse>();
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user