forked from ddrilling/AsbCloudServer
Изменение API
1. Добавлен контроллер TelemetryInfoController
This commit is contained in:
parent
cdaae721be
commit
5a8d1e448d
50
AsbCloudWebApi/Controllers/TelemetryInfoController.cs
Normal file
50
AsbCloudWebApi/Controllers/TelemetryInfoController.cs
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user