DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/VersionController.cs

50 lines
1.3 KiB
C#
Raw Normal View History

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 VersionController : ControllerBase
{
private readonly ITelemetryService telemetryService;
public VersionController(ITelemetryService telemetryService)
{
this.telemetryService = telemetryService;
}
/// <summary>
/// Получить список версий ПО
/// </summary>
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
[HttpGet]
[Permission]
[ProducesResponseType(typeof(IEnumerable<VersionDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetAsync([FromQuery] VersionRequestBase request, CancellationToken token)
{
var idCompany = User.GetCompanyId();
if (!idCompany.HasValue)
return Forbid();
var requestToService = new VersionRequest(idCompany.Value, request);
var version = await telemetryService.GetVersionsAsync(requestToService, token);
return Ok(version);
}
}