Добавить DocumentationFile, описание контроллеров
This commit is contained in:
parent
0234f2096d
commit
dc66522c0f
@ -4,6 +4,10 @@ using Persistence.Repositories;
|
|||||||
using Persistence.Repository.Data;
|
using Persistence.Repository.Data;
|
||||||
|
|
||||||
namespace Persistence.API.Controllers;
|
namespace Persistence.API.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <20>אבמעא ס גנולוםם<D79D>לט האםם<D79D>לט
|
||||||
|
/// </summary>
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
|
@ -3,51 +3,79 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Persistence.Models;
|
using Persistence.Models;
|
||||||
using Persistence.Repositories;
|
using Persistence.Repositories;
|
||||||
|
|
||||||
namespace Persistence.API.Controllers
|
namespace Persistence.API.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Работа с уставками
|
||||||
|
/// </summary>
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class SetpointController : ControllerBase, ISetpointApi
|
||||||
{
|
{
|
||||||
[ApiController]
|
private readonly ISetpointRepository setpointRepository;
|
||||||
[Authorize]
|
|
||||||
[Route("api/[controller]")]
|
public SetpointController(ISetpointRepository setpointRepository)
|
||||||
public class SetpointController : ControllerBase, ISetpointApi
|
|
||||||
{
|
{
|
||||||
private readonly ISetpointRepository setpointRepository;
|
this.setpointRepository = setpointRepository;
|
||||||
|
}
|
||||||
|
|
||||||
public SetpointController(ISetpointRepository setpointRepository)
|
/// <summary>
|
||||||
{
|
/// Получить актуальные значения уставок
|
||||||
this.setpointRepository = setpointRepository;
|
/// </summary>
|
||||||
}
|
/// <param name="setpointKeys"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("current")]
|
||||||
|
public async Task<ActionResult<IEnumerable<SetpointValueDto>>> GetCurrent([FromQuery] IEnumerable<Guid> setpointKeys, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = await setpointRepository.GetCurrent(setpointKeys, token);
|
||||||
|
|
||||||
[HttpGet("current")]
|
return Ok(result);
|
||||||
public async Task<ActionResult<IEnumerable<SetpointValueDto>>> GetCurrent([FromQuery] IEnumerable<Guid> setpointKeys, CancellationToken token)
|
}
|
||||||
{
|
|
||||||
var result = await setpointRepository.GetCurrent(setpointKeys, token);
|
|
||||||
|
|
||||||
return Ok(result);
|
/// <summary>
|
||||||
}
|
/// Получить значения уставок за определенный момент времени
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="setpointKeys"></param>
|
||||||
|
/// <param name="historyMoment"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("history")]
|
||||||
|
public async Task<ActionResult<IEnumerable<SetpointValueDto>>> GetHistory([FromQuery] IEnumerable<Guid> setpointKeys, [FromQuery] DateTimeOffset historyMoment, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = await setpointRepository.GetHistory(setpointKeys, historyMoment, token);
|
||||||
|
|
||||||
[HttpGet("history")]
|
return Ok(result);
|
||||||
public async Task<ActionResult<IEnumerable<SetpointValueDto>>> GetHistory([FromQuery] IEnumerable<Guid> setpointKeys, [FromQuery] DateTimeOffset historyMoment, CancellationToken token)
|
}
|
||||||
{
|
|
||||||
var result = await setpointRepository.GetHistory(setpointKeys, historyMoment, token);
|
|
||||||
|
|
||||||
return Ok(result);
|
/// <summary>
|
||||||
}
|
/// Получить историю изменений значений уставок
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="setpointKeys"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("log")]
|
||||||
|
public async Task<ActionResult<Dictionary<Guid, IEnumerable<SetpointLogDto>>>> GetLog([FromQuery] IEnumerable<Guid> setpointKeys, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = await setpointRepository.GetLog(setpointKeys, token);
|
||||||
|
|
||||||
[HttpGet("log")]
|
return Ok(result);
|
||||||
public async Task<ActionResult<Dictionary<Guid, IEnumerable<SetpointLogDto>>>> GetLog([FromQuery] IEnumerable<Guid> setpointKeys, CancellationToken token)
|
}
|
||||||
{
|
|
||||||
var result = await setpointRepository.GetLog(setpointKeys, token);
|
|
||||||
|
|
||||||
return Ok(result);
|
/// <summary>
|
||||||
}
|
/// Сохранить уставку
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="setpointKey"></param>
|
||||||
|
/// <param name="newValue"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<int>> Save(Guid setpointKey, object newValue, CancellationToken token)
|
||||||
|
{
|
||||||
|
// ToDo: вычитка idUser
|
||||||
|
await setpointRepository.Save(setpointKey, newValue, 0, token);
|
||||||
|
|
||||||
[HttpPost]
|
return Ok();
|
||||||
public async Task<ActionResult<int>> Save(Guid setpointKey, object newValue, CancellationToken token)
|
|
||||||
{
|
|
||||||
// ToDo: вычитка idUser
|
|
||||||
await setpointRepository.Save(setpointKey, newValue, 0, token);
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,65 +3,95 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Persistence.Models;
|
using Persistence.Models;
|
||||||
using Persistence.Repositories;
|
using Persistence.Repositories;
|
||||||
|
|
||||||
namespace Persistence.API.Controllers
|
namespace Persistence.API.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Работа с состояниями систем автобурения (АБ)
|
||||||
|
/// </summary>
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class TechMessagesController : ControllerBase, ITechMessages
|
||||||
{
|
{
|
||||||
[ApiController]
|
private readonly ITechMessagesRepository techMessagesRepository;
|
||||||
[Authorize]
|
|
||||||
[Route("api/[controller]")]
|
public TechMessagesController(ITechMessagesRepository techMessagesRepository)
|
||||||
public class TechMessagesController : ControllerBase, ITechMessages
|
|
||||||
{
|
{
|
||||||
private readonly ITechMessagesRepository techMessagesRepository;
|
this.techMessagesRepository = techMessagesRepository;
|
||||||
|
}
|
||||||
|
|
||||||
public TechMessagesController(ITechMessagesRepository techMessagesRepository)
|
/// <summary>
|
||||||
|
/// Получить список технологических сообщений в виде страницы
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<ActionResult<PaginationContainer<TechMessageDto>>> GetPage([FromQuery] RequestDto request, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = await techMessagesRepository.GetPage(request, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить статистику по системам
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="importantId"></param>
|
||||||
|
/// <param name="autoDrillingSystem"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("statistics")]
|
||||||
|
public async Task<ActionResult<int>> GetStatistics(int importantId, string autoDrillingSystem, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = await techMessagesRepository.GetStatistics(importantId, autoDrillingSystem, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить список всех систем
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("systems")]
|
||||||
|
public async Task<ActionResult<IEnumerable<string>>> GetSystems(CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = await techMessagesRepository.GetSystems(token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Добавить новые технологические сообщения
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dtos"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<int>> InsertRange([FromBody] IEnumerable<TechMessageDto> dtos, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = await techMessagesRepository.InsertRange(dtos, token);
|
||||||
|
|
||||||
|
return CreatedAtAction(nameof(InsertRange), result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить словарь категорий
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("categories")]
|
||||||
|
public ActionResult<Dictionary<int, string>> GetImportantCategories()
|
||||||
|
{
|
||||||
|
var result = new Dictionary<int, string>()
|
||||||
{
|
{
|
||||||
this.techMessagesRepository = techMessagesRepository;
|
{ 0, "System" },
|
||||||
}
|
{ 1, "Авария" },
|
||||||
|
{ 2, "Предупреждение" },
|
||||||
|
{ 3, "Инфо" },
|
||||||
|
{ 4, "Прочее" }
|
||||||
|
};
|
||||||
|
|
||||||
[HttpGet]
|
return Ok(result);
|
||||||
public async Task<ActionResult<PaginationContainer<TechMessageDto>>> GetPage([FromQuery] RequestDto request, CancellationToken token)
|
|
||||||
{
|
|
||||||
var result = await techMessagesRepository.GetPage(request, token);
|
|
||||||
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("statistics")]
|
|
||||||
public async Task<ActionResult<int>> GetStatistics(int importantId, string autoDrillingSystem, CancellationToken token)
|
|
||||||
{
|
|
||||||
var result = await techMessagesRepository.GetStatistics(importantId, autoDrillingSystem, token);
|
|
||||||
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("systems")]
|
|
||||||
public async Task<ActionResult<IEnumerable<string>>> GetSystems(CancellationToken token)
|
|
||||||
{
|
|
||||||
var result = await techMessagesRepository.GetSystems(token);
|
|
||||||
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public async Task<ActionResult<int>> InsertRange([FromBody] IEnumerable<TechMessageDto> dtos, CancellationToken token)
|
|
||||||
{
|
|
||||||
var result = await techMessagesRepository.InsertRange(dtos, token);
|
|
||||||
|
|
||||||
return CreatedAtAction(nameof(InsertRange), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("categories")]
|
|
||||||
public ActionResult<Dictionary<int, string>> GetImportantCategories()
|
|
||||||
{
|
|
||||||
var result = new Dictionary<int, string>()
|
|
||||||
{
|
|
||||||
{ 0, "System" },
|
|
||||||
{ 1, "Авария" },
|
|
||||||
{ 2, "Предупреждение" },
|
|
||||||
{ 3, "Инфо" },
|
|
||||||
{ 4, "Прочее" }
|
|
||||||
};
|
|
||||||
|
|
||||||
return Ok(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using Persistence.Models;
|
|||||||
using Persistence.Repositories;
|
using Persistence.Repositories;
|
||||||
|
|
||||||
namespace Persistence.API.Controllers;
|
namespace Persistence.API.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
@ -12,12 +13,18 @@ public class TimeSeriesController<TDto> : ControllerBase, ITimeSeriesDataApi<TDt
|
|||||||
{
|
{
|
||||||
private ITimeSeriesDataRepository<TDto> timeSeriesDataRepository;
|
private ITimeSeriesDataRepository<TDto> timeSeriesDataRepository;
|
||||||
|
|
||||||
public TimeSeriesController(ITimeSeriesDataRepository<TDto> timeSeriesDataRepository)
|
public TimeSeriesController(ITimeSeriesDataRepository<TDto> timeSeriesDataRepository)
|
||||||
{
|
{
|
||||||
this.timeSeriesDataRepository = timeSeriesDataRepository;
|
this.timeSeriesDataRepository = timeSeriesDataRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
/// <summary>
|
||||||
|
/// Ïîëó÷èòü ñïèñîê îáúåêòîâ, óäîâëåòâîðÿþùèé äèàïàçîíó äàò
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateBegin"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> Get(DateTimeOffset dateBegin, CancellationToken token)
|
public async Task<IActionResult> Get(DateTimeOffset dateBegin, CancellationToken token)
|
||||||
{
|
{
|
||||||
@ -25,21 +32,40 @@ public class TimeSeriesController<TDto> : ControllerBase, ITimeSeriesDataApi<TDt
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("datesRange")]
|
/// <summary>
|
||||||
|
/// Ïîëó÷èòü äèàïàçîí äàò, äëÿ êîòîðûõ åñòü äàííûå â ðåïîçèòîðèå
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("datesRange")]
|
||||||
public async Task<IActionResult> GetDatesRange(CancellationToken token)
|
public async Task<IActionResult> GetDatesRange(CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await this.timeSeriesDataRepository.GetDatesRange(token);
|
var result = await this.timeSeriesDataRepository.GetDatesRange(token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("resampled")]
|
/// <summary>
|
||||||
|
/// Ïîëó÷èòü ñïèñîê îáúåêòîâ ñ ïðîðåæèâàíèåì, óäîâëåòâîðÿþùèé äèàïàçîíó äàò
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateBegin"></param>
|
||||||
|
/// <param name="intervalSec"></param>
|
||||||
|
/// <param name="approxPointsCount"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("resampled")]
|
||||||
public async Task<IActionResult> GetResampledData(DateTimeOffset dateBegin, double intervalSec = 600d, int approxPointsCount = 1024, CancellationToken token = default)
|
public async Task<IActionResult> GetResampledData(DateTimeOffset dateBegin, double intervalSec = 600d, int approxPointsCount = 1024, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var result = await this.timeSeriesDataRepository.GetResampledData(dateBegin, intervalSec, approxPointsCount, token);
|
var result = await this.timeSeriesDataRepository.GetResampledData(dateBegin, intervalSec, approxPointsCount, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
/// <summary>
|
||||||
|
/// Äîáàâèòü çàïèñè
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dtos"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
public async Task<IActionResult> InsertRange(IEnumerable<TDto> dtos, CancellationToken token)
|
public async Task<IActionResult> InsertRange(IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await this.timeSeriesDataRepository.InsertRange(dtos, token);
|
var result = await this.timeSeriesDataRepository.InsertRange(dtos, token);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Reflection;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
@ -38,11 +39,10 @@ public static class DependencyInjection
|
|||||||
c.AddKeycloackSecurity(configuration);
|
c.AddKeycloackSecurity(configuration);
|
||||||
else c.AddDefaultSecurity(configuration);
|
else c.AddDefaultSecurity(configuration);
|
||||||
|
|
||||||
//var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||||
//var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||||
//var includeControllerXmlComment = true;
|
var includeControllerXmlComment = true;
|
||||||
//options.IncludeXmlComments(xmlPath, includeControllerXmlComment);
|
c.IncludeXmlComments(xmlPath, includeControllerXmlComment);
|
||||||
//options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "AsbCloudApp.xml"), includeControllerXmlComment);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
|
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user