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