2021-07-19 15:11:01 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
|
|
|
|
using AsbCloudApp.Services;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi.Controllers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Контроллер кустов
|
|
|
|
|
/// </summary>
|
2021-07-19 15:57:51 +05:00
|
|
|
|
[Route("api/cluster")]
|
2021-07-19 15:11:01 +05:00
|
|
|
|
[ApiController]
|
|
|
|
|
[Authorize]
|
|
|
|
|
public class ClusterController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly IClusterService clusterService;
|
|
|
|
|
|
|
|
|
|
public ClusterController(IClusterService clusterService)
|
|
|
|
|
{
|
|
|
|
|
this.clusterService = clusterService;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 15:57:51 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получает список доступных пользователю кустов
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet()]
|
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<ClusterDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public IActionResult GetClusters()
|
|
|
|
|
{
|
|
|
|
|
int? idCustomer = User.GetCustomerId();
|
|
|
|
|
|
|
|
|
|
if (idCustomer is null)
|
|
|
|
|
return Forbid();
|
|
|
|
|
|
|
|
|
|
var result = clusterService.GetClusters((int)idCustomer);
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-19 15:11:01 +05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получение доступных пользователю скважин
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="clusterId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("{clusterId}")]
|
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public IActionResult GetWells(int clusterId)
|
|
|
|
|
{
|
|
|
|
|
int? idCustomer = User.GetCustomerId();
|
|
|
|
|
|
|
|
|
|
if (idCustomer is null)
|
|
|
|
|
return Forbid();
|
|
|
|
|
|
|
|
|
|
var result = clusterService.GetWells((int)idCustomer, clusterId);
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Получение обопщенной аналитики по кусту (лучшая/худшая скважина)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="clusterId"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-07-19 15:31:50 +05:00
|
|
|
|
[HttpGet("{clusterId}/Analysis")]
|
2021-07-19 15:11:01 +05:00
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<ClusterAnalysisDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
|
public IActionResult GetAnalysis(int clusterId)
|
|
|
|
|
{
|
|
|
|
|
int? idCustomer = User.GetCustomerId();
|
|
|
|
|
|
|
|
|
|
if (idCustomer is null)
|
|
|
|
|
return Forbid();
|
|
|
|
|
|
|
|
|
|
var result = clusterService.GetAnalysis((int)idCustomer, clusterId);
|
|
|
|
|
return Ok(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|