Изменение API

1. Добавлен контроллер TelemetryInfoController
This commit is contained in:
Степанов Дмитрий 2024-08-21 14:53:50 +05:00
parent cdaae721be
commit 5a8d1e448d

View File

@ -0,0 +1,50 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data.SAUB;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace AsbCloudWebApi.Controllers;
/// <summary>
/// Информация о телеметрии
/// </summary>
[Route("api/[controller]")]
[ApiController]
[Authorize]
public class TelemetryInfoController : ControllerBase
{
private readonly ITelemetryService telemetryService;
public TelemetryInfoController(ITelemetryService telemetryService)
{
this.telemetryService = telemetryService;
}
/// <summary>
/// Получить список информации о телеметрии
/// </summary>
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
[HttpGet]
[Permission]
[ProducesResponseType(typeof(IEnumerable<TelemetryInfoDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetAsync([FromQuery] TelemetryInfoRequestBase request, CancellationToken token)
{
var idCompany = User.GetCompanyId();
if (!idCompany.HasValue)
return Forbid();
var requestToService = new TelemetryInfoRequest(idCompany.Value, request);
var telemetriesInfo = await telemetryService.GetInfoAsync(requestToService, token);
return Ok(telemetriesInfo);
}
}