DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/VersionController.cs
Степанов Дмитрий 1a9ad8a904 Правки после ревью
1. Изменил нейминг
2. Поправил метод получения версии ПО. Поправил кеширование
3. В запрос добавил дополнительные прафила фильтрации
2024-08-27 16:57:22 +05:00

50 lines
1.3 KiB
C#

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);
}
}