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

78 lines
2.5 KiB
C#
Raw Normal View History

using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
namespace AsbCloudWebApi.Controllers
{
/// <summary>
/// Контроллер кустов
/// </summary>
[Route("api/cluster")]
[ApiController]
[Authorize]
public class ClusterController : ControllerBase
{
private readonly IClusterService clusterService;
public ClusterController(IClusterService clusterService)
{
this.clusterService = clusterService;
}
/// <summary>
/// Получает список доступных пользователю кустов
/// </summary>
/// <returns></returns>
[HttpGet()]
[ProducesResponseType(typeof(IEnumerable<ClusterDto>), (int)System.Net.HttpStatusCode.OK)]
public IActionResult GetClusters()
{
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();
2021-07-21 15:22:58 +05:00
var result = clusterService.GetClusters((int)idCompany);
return Ok(result);
}
/// <summary>
/// Получение доступных пользователю скважин
/// </summary>
2021-07-21 15:29:19 +05:00
/// <param name="idCluster"></param>
/// <returns></returns>
2021-07-21 15:29:19 +05:00
[HttpGet("{idCluster}")]
[ProducesResponseType(typeof(IEnumerable<WellDto>), (int)System.Net.HttpStatusCode.OK)]
2021-07-21 15:29:19 +05:00
public IActionResult GetWells(int idCluster)
{
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();
2021-07-21 15:29:19 +05:00
var result = clusterService.GetWells((int)idCompany, idCluster);
return Ok(result);
}
/// <summary>
2021-07-21 15:29:19 +05:00
/// Получение обопщенной статистики по кусту (лучшая/худшая скважина)
/// </summary>
2021-07-21 15:29:19 +05:00
/// <param name="idCluster"></param>
/// <returns></returns>
2021-07-21 15:29:19 +05:00
[HttpGet("{idCluster}/Stat")]
2021-07-21 18:03:45 +05:00
[ProducesResponseType(typeof(ClusterStatDto), (int)System.Net.HttpStatusCode.OK)]
2021-07-21 15:29:19 +05:00
public IActionResult GetStat(int idCluster)
{
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();
2021-07-21 15:29:19 +05:00
var result = clusterService.GetStat((int)idCompany, idCluster);
return Ok(result);
}
}
}