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

52 lines
1.6 KiB
C#
Raw Permalink Normal View History

using AsbCloudApp.Data;
2023-10-03 09:12:26 +05:00
using AsbCloudApp.Exceptions;
using AsbCloudApp.Requests;
2023-10-03 15:32:58 +05:00
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
2024-08-19 10:01:07 +05:00
namespace AsbCloudWebApi.Controllers;
/// <summary>
/// Аналитика по удержанию в клиньях
/// </summary>
[Route("api/slipsStat")]
[ApiController]
[Authorize]
public class SlipsStatController : ControllerBase
{
2024-08-19 10:01:07 +05:00
private readonly ISlipsStatService slipsAnalyticsService;
public SlipsStatController(ISlipsStatService slipsAnalyticsService)
{
this.slipsAnalyticsService = slipsAnalyticsService;
}
/// <summary>
2024-08-19 10:01:07 +05:00
/// Получить аналитику по удержанию в клиньях (по бурильщикам)
/// </summary>
2024-08-19 10:01:07 +05:00
/// <param name="request">Параметры запроса</param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns>Список бурильщиков</returns>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<SlipsStatDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetAllAsync(
[FromQuery] OperationStatRequest request,
CancellationToken token)
{
2024-08-19 10:01:07 +05:00
var idUser = User.GetUserId();
2024-08-19 10:01:07 +05:00
if (!idUser.HasValue)
throw new ForbidException("Не удается вас опознать");
2023-10-03 09:12:26 +05:00
2024-08-19 10:01:07 +05:00
var data = await slipsAnalyticsService.GetAllAsync(request, token).ConfigureAwait(false);
return Ok(data);
}
}