forked from ddrilling/AsbCloudServer
61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
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/deposit")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class DepositController : ControllerBase
|
|
{
|
|
IClusterService clusterService;
|
|
|
|
public DepositController(IClusterService clusterService)
|
|
{
|
|
this.clusterService = clusterService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получает список доступных пользователю месторождений
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[ProducesResponseType(typeof(IEnumerable<DepositDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
public IActionResult GetDeposits()
|
|
{
|
|
int? idCompany = User.GetCompanyId();
|
|
|
|
if (idCompany is null)
|
|
return Forbid();
|
|
|
|
var result = clusterService.GetDeposits((int)idCompany);
|
|
return Ok(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получает список доступных пользователю кустов месторождения
|
|
/// </summary>
|
|
/// <param name="depositId"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("{depositId}")]
|
|
[ProducesResponseType(typeof(IEnumerable<ClusterDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
public IActionResult GetClusters(int depositId)
|
|
{
|
|
int? idCompany = User.GetCompanyId();
|
|
|
|
if (idCompany is null)
|
|
return Forbid();
|
|
|
|
var result = clusterService.GetClusters((int)idCompany, depositId);
|
|
return Ok(result);
|
|
}
|
|
|
|
}
|
|
}
|