feat(api,core,domain): Получение снапшотов работы роботов
This commit is contained in:
@@ -258,6 +258,7 @@
|
||||
|
||||
public static class StatRobotSnapshot
|
||||
{
|
||||
public const string GetAll = BaseStat + "/robot-snapshots/";
|
||||
public const string Create = BaseStat + "/robot-snapshots/";
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||
{
|
||||
public record StatRobotSnapshotQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// IP робота
|
||||
/// </summary>
|
||||
public string? Ip { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Кол-во минут от текущего времени, по умолчнию 12 часов.
|
||||
/// </summary>
|
||||
public int Minutes { get; init; } = 12 * 60;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,13 @@
|
||||
namespace PARR.API.Contracts.V1.Responses.Statistics
|
||||
{
|
||||
public record StatRobotSnapshotItemResponse
|
||||
{
|
||||
public required UserBaseResponse Robot { get; init; }
|
||||
|
||||
public List<StatRobotSnapshotResponse> Snapshots { get; init; } = new();
|
||||
}
|
||||
|
||||
public record StatRobotSnapshotResponse
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
|
||||
@@ -11,7 +18,5 @@
|
||||
public int ScheduleRobotsCount { get; init; }
|
||||
|
||||
public int MaxRobots { get; init; }
|
||||
|
||||
public required string Ip { get; init; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
@@ -13,7 +14,7 @@ using PARR.Domain.DTOs.RobotSnapshotDTO;
|
||||
|
||||
namespace PARR.API.Controllers.V1.Statistics
|
||||
{
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
[Authorize]
|
||||
public class StatRobotSnapshotController : BaseApiController
|
||||
{
|
||||
private readonly IRobotSnapshotService robotSnapshotService;
|
||||
@@ -31,6 +32,28 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить снапшоты роботов.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
[HttpGet(ApiRoutes.StatRobotSnapshot.GetAll)]
|
||||
public async Task<IActionResult> GetAll([FromQuery] StatRobotSnapshotQuery query)
|
||||
{
|
||||
var queryDto = mapper.Map<RobotSnapshotQuery>(query);
|
||||
|
||||
var snapshots = await robotSnapshotService.GetAsync(queryDto);
|
||||
|
||||
if (snapshots.Count == 0)
|
||||
return NoContent();
|
||||
|
||||
var response = mapper.Map<List<StatRobotSnapshotItemResponse>>(snapshots);
|
||||
|
||||
return Ok(new Response<List<StatRobotSnapshotItemResponse>>(response, true));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Отправить снапшот роботов.
|
||||
/// Доступ только с ролью "Робот ЕСПП"
|
||||
|
||||
@@ -9,6 +9,7 @@ using PARR.Domain.DTOs.RobotSnapshotDTO;
|
||||
using PARR.Domain.DTOs.RobotTask;
|
||||
using PARR.Domain.DTOs.Shortcode;
|
||||
using PARR.Domain.DTOs.TaskDTO;
|
||||
using PARR.Domain.DTOs.User;
|
||||
using PARR.Domain.DTOs.Workload;
|
||||
using PARR.Domain.Entities;
|
||||
using PARR.Domain.Entities.Base.History;
|
||||
@@ -312,6 +313,8 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
CreateMap<UserCache, UserProfileResponse>();
|
||||
|
||||
CreateMap<UserBaseDto, UserBaseResponse>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Order
|
||||
@@ -486,8 +489,13 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
#endregion
|
||||
|
||||
#region RobotSnapshot
|
||||
|
||||
CreateMap<RobotSnapshotItem, StatRobotSnapshotItemResponse>();
|
||||
CreateMap<RobotSnapshotDto, StatRobotSnapshotResponse>();
|
||||
|
||||
CreateMap<RobotSnapshotItemDto, StatRobotSnapshotItemResponse>();
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using PARR.API.Contracts.V1.Requests;
|
||||
using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.DTOs.RobotSnapshotDTO;
|
||||
using PARR.Domain.Entities.Job;
|
||||
|
||||
namespace PARR.API.MappingProfiles
|
||||
@@ -45,6 +46,8 @@ namespace PARR.API.MappingProfiles
|
||||
CreateMap<RelationshipFilterRequest, JobRelationshipFilter>();
|
||||
|
||||
#endregion
|
||||
|
||||
CreateMap<StatRobotSnapshotQuery, RobotSnapshotQuery>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user