forked from ddrilling/AsbCloudServer
WellController. Объединил GetAsync и GetStatAsync в GetAsync.
This commit is contained in:
parent
0230432c8c
commit
1fac8ef565
@ -25,6 +25,14 @@ namespace AsbCloudApp.Services
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<WellDto>> GetAsync(WellRequest request, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Статистика по скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<WellMapInfoWithTelemetryStat?> GetOrDefaultStatAsync(int idWell, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// проверяет доступ к скважине для компании
|
||||
/// </summary>
|
||||
@ -34,6 +42,7 @@ namespace AsbCloudApp.Services
|
||||
/// <returns></returns>
|
||||
Task<bool> IsCompanyInvolvedInWellAsync(int idCompany, int idWell, CancellationToken token);
|
||||
|
||||
//TODO: remove that
|
||||
/// <summary>
|
||||
/// получить название скважины по id
|
||||
/// </summary>
|
||||
@ -102,13 +111,5 @@ namespace AsbCloudApp.Services
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<DepositBranchDto>> GetWellTreeAsync(int idCompany, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Статистика по скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<WellMapInfoWithTelemetryStat?> GetOrDefaultStatAsync(int idWell, CancellationToken token);
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,8 @@ namespace AsbCloudWebApi.Controllers
|
||||
/// <returns>Информация о требуемой скважине </returns>
|
||||
[HttpGet("{idWell}")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(WellDto), (int)System.Net.HttpStatusCode.OK)]
|
||||
[ProducesResponseType(typeof(WellMapInfoWithTelemetryStat), (int)System.Net.HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)System.Net.HttpStatusCode.NoContent)]
|
||||
public async Task<IActionResult> GetAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
@ -82,30 +83,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync(idCompany ?? default, idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var well = await wellService.GetOrDefaultAsync(idWell,
|
||||
token).ConfigureAwait(false);
|
||||
|
||||
return Ok(well);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает информацию о требуемой скважине
|
||||
/// </summary>
|
||||
/// <param name="idWell"> Id требуемой скважины </param>
|
||||
/// <param name="token"> Токен отмены задачи </param>
|
||||
/// <returns>Информация о требуемой скважине </returns>
|
||||
[HttpGet("{idWell}/info")]
|
||||
[Permission]
|
||||
[ProducesResponseType(typeof(WellDto), (int)System.Net.HttpStatusCode.OK)]
|
||||
public async Task<IActionResult> GetStatAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var idCompany = User.GetCompanyId();
|
||||
|
||||
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync(idCompany ?? default, idWell, token).ConfigureAwait(false))
|
||||
return Forbid();
|
||||
|
||||
var well = await wellService.GetOrDefaultStatAsync(idWell,
|
||||
token);
|
||||
var well = await wellService.GetOrDefaultStatAsync(idWell, token);
|
||||
|
||||
return Ok(well);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user