using AsbCloudApp.Data; using AsbCloudApp.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; namespace AsbCloudWebApi.Controllers { /// /// Контроллер кустов /// [Route("api/cluster")] [ApiController] [Authorize] public class ClusterController : ControllerBase { private readonly IClusterService clusterService; public ClusterController(IClusterService clusterService) { this.clusterService = clusterService; } /// /// Получает список доступных пользователю кустов /// /// [HttpGet()] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetClusters() { int? idCompany = User.GetCompanyId(); if (idCompany is null) return Forbid(); var result = clusterService.GetClusters((int)idCompany); return Ok(result); } /// /// Получение доступных пользователю скважин /// /// /// [HttpGet("{idCluster}")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetWells(int idCluster) { int? idCompany = User.GetCompanyId(); if (idCompany is null) return Forbid(); var result = clusterService.GetWells((int)idCompany, idCluster); return Ok(result); } /// /// Получение обопщенной статистики по кусту (лучшая/худшая скважина) /// /// /// [HttpGet("{idCluster}/Stat")] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public IActionResult GetStat(int idCluster) { int? idCompany = User.GetCompanyId(); if (idCompany is null) return Forbid(); var result = clusterService.GetStat((int)idCompany, idCluster); return Ok(result); } } }