2023-10-02 17:53:34 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
2023-10-03 09:12:26 +05:00
|
|
|
|
using AsbCloudApp.Exceptions;
|
2023-10-02 17:53:34 +05:00
|
|
|
|
using AsbCloudApp.Requests;
|
2023-10-03 15:32:58 +05:00
|
|
|
|
using AsbCloudApp.Services;
|
2023-10-02 17:53:34 +05:00
|
|
|
|
using AsbCloudDb.Model;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Аналитика по удержанию в клиньях
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Route("api/slipsStat")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Authorize]
|
|
|
|
|
public class SlipsStatController : ControllerBase
|
|
|
|
|
{
|
2023-10-03 15:32:58 +05:00
|
|
|
|
private readonly ISlipsStatService slipsAnalyticsService;
|
2023-10-02 17:53:34 +05:00
|
|
|
|
|
2023-10-03 15:32:58 +05:00
|
|
|
|
public SlipsStatController(ISlipsStatService slipsAnalyticsService)
|
2023-10-02 17:53:34 +05:00
|
|
|
|
{
|
|
|
|
|
this.slipsAnalyticsService = slipsAnalyticsService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получить аналитику по удержанию в клиньях (по бурильщикам)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <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)
|
|
|
|
|
{
|
2023-10-03 09:12:26 +05:00
|
|
|
|
var idUser = User.GetUserId();
|
2023-10-02 17:53:34 +05:00
|
|
|
|
|
2023-10-03 09:12:26 +05:00
|
|
|
|
if (!idUser.HasValue)
|
|
|
|
|
throw new ForbidException("Не удается вас опознать");
|
|
|
|
|
|
|
|
|
|
var data = await slipsAnalyticsService.GetAllAsync(request, token).ConfigureAwait(false);
|
|
|
|
|
return Ok(data);
|
2023-10-02 17:53:34 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|