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