forked from ddrilling/AsbCloudServer
65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
|
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>
|
|||
|
[Route("api/[controller]")]
|
|||
|
[ApiController]
|
|||
|
[Authorize]
|
|||
|
public class ClusterController : ControllerBase
|
|||
|
{
|
|||
|
private readonly IClusterService clusterService;
|
|||
|
|
|||
|
public ClusterController(IClusterService clusterService)
|
|||
|
{
|
|||
|
this.clusterService = clusterService;
|
|||
|
}
|
|||
|
|
|||
|
/// <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>
|
|||
|
[HttpGet("{clusterId}")]
|
|||
|
[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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|