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

90 lines
3.2 KiB
C#
Raw Normal View History

using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
/// <summary>
2022-06-16 17:37:10 +05:00
/// Инфо о месторождениях
/// </summary>
[Route("api/deposit")]
[ApiController]
[Authorize]
public class DepositController : ControllerBase
{
2021-07-21 17:23:57 +05:00
private readonly IClusterService clusterService;
public DepositController(IClusterService clusterService)
{
this.clusterService = clusterService;
}
/// <summary>
/// Получает список доступных пользователю месторождений
/// </summary>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpGet]
[Permission]
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetDepositsAsync(CancellationToken token = default)
{
2021-07-21 15:22:58 +05:00
int? idCompany = User.GetCompanyId();
2021-07-21 15:22:58 +05:00
if (idCompany is null)
return Forbid();
var result = await clusterService.GetDepositsAsync((int)idCompany,
token).ConfigureAwait(false);
return Ok(result);
}
2022-04-11 18:00:34 +05:00
/// <summary>
/// Получает список доступных пользователю месторождений (только скважины с параметрами бурения)
/// </summary>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpGet("drillParamsWells")]
[Permission]
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetDepositsDrillParamsAsync(CancellationToken token = default)
{
int? idCompany = User.GetCompanyId();
if (idCompany is null)
return Forbid();
var result = await clusterService.GetDepositsDrillParamsAsync((int)idCompany,
token).ConfigureAwait(false);
return Ok(result);
}
/// <summary>
/// Получает список доступных пользователю кустов месторождения
/// </summary>
/// <param name="depositId"></param>
/// <param name="token"> Токен отмены задачи </param>
/// <returns></returns>
[HttpGet("{depositId}")]
[Permission]
[ProducesResponseType(typeof(IEnumerable<ClusterDto>), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetClustersAsync(int depositId,
CancellationToken token = default)
{
2021-07-21 15:22:58 +05:00
int? idCompany = User.GetCompanyId();
2021-07-21 15:22:58 +05:00
if (idCompany is null)
return Forbid();
var result = await clusterService.GetClustersAsync((int)idCompany,
depositId, token).ConfigureAwait(false);
return Ok(result);
}
}
}