diff --git a/Persistence.API/Controllers/DataSaubController.cs b/Persistence.API/Controllers/DataSaubController.cs
index 437aee3..202e527 100644
--- a/Persistence.API/Controllers/DataSaubController.cs
+++ b/Persistence.API/Controllers/DataSaubController.cs
@@ -6,7 +6,7 @@ using Persistence.Repository.Data;
namespace Persistence.API.Controllers;
///
-///
+/// Работа с временными данными
///
[ApiController]
[Authorize]
diff --git a/Persistence.API/Controllers/SetpointController.cs b/Persistence.API/Controllers/SetpointController.cs
index 5a5cb52..108c3ef 100644
--- a/Persistence.API/Controllers/SetpointController.cs
+++ b/Persistence.API/Controllers/SetpointController.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Authorization;
+using System.Net;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Persistence.Models;
using Persistence.Repositories;
@@ -63,18 +64,47 @@ public class SetpointController : ControllerBase, ISetpointApi
return Ok(result);
}
+ ///
+ /// Получить диапазон дат, для которых есть данные в репозитории
+ ///
+ ///
+ ///
+ [HttpGet("range")]
+ public async Task> GetDatesRangeAsync(CancellationToken token)
+ {
+ var result = await setpointRepository.GetDatesRangeAsync(token);
+
+ return Ok(result);
+ }
+
+ ///
+ /// Получить порцию записей, начиная с заданной даты
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("part")]
+ public async Task>> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token)
+ {
+ var result = await setpointRepository.GetPart(dateBegin, take, token);
+
+ return Ok(result);
+ }
+
///
/// Сохранить уставку
///
///
///
+ ///
///
///
[HttpPost]
- public async Task> Save(Guid setpointKey, object newValue, CancellationToken token)
+ [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)]
+ public async Task Save(Guid setpointKey, object newValue, Guid idUser, CancellationToken token)
{
- // ToDo: вычитка idUser
- await setpointRepository.Save(setpointKey, newValue, 0, token);
+ await setpointRepository.Save(setpointKey, newValue, idUser, token);
return Ok();
}
diff --git a/Persistence.API/Controllers/TechMessagesController.cs b/Persistence.API/Controllers/TechMessagesController.cs
index fb3315e..4e91802 100644
--- a/Persistence.API/Controllers/TechMessagesController.cs
+++ b/Persistence.API/Controllers/TechMessagesController.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Authorization;
+using System.Net;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Persistence.Models;
using Persistence.Repositories;
@@ -14,6 +15,14 @@ namespace Persistence.API.Controllers;
public class TechMessagesController : ControllerBase
{
private readonly ITechMessagesRepository techMessagesRepository;
+ private static readonly Dictionary categories = new Dictionary()
+ {
+ { 0, "System" },
+ { 1, "Авария" },
+ { 2, "Предупреждение" },
+ { 3, "Инфо" },
+ { 4, "Прочее" }
+ };
public TechMessagesController(ITechMessagesRepository techMessagesRepository)
{
@@ -37,14 +46,14 @@ public class TechMessagesController : ControllerBase
///
/// Получить статистику по системам
///
- ///
///
+ ///
///
///
- [HttpGet("statistics/{autoDrillingSystem}")]
- public async Task> GetStatistics([FromRoute] string? autoDrillingSystem, int? importantId, CancellationToken token)
+ [HttpGet("statistics")]
+ public async Task>> GetStatistics([FromQuery] IEnumerable autoDrillingSystem, [FromQuery] IEnumerable categoryIds, CancellationToken token)
{
- var result = await techMessagesRepository.GetStatistics(importantId, autoDrillingSystem, token);
+ var result = await techMessagesRepository.GetStatistics(autoDrillingSystem, categoryIds, token);
return Ok(result);
}
@@ -55,13 +64,41 @@ public class TechMessagesController : ControllerBase
///
///
[HttpGet("systems")]
- public async Task>> GetSystems(CancellationToken token)
+ public async Task>> GetSystems(CancellationToken token)
{
var result = await techMessagesRepository.GetSystems(token);
return Ok(result);
}
+ ///
+ /// Получить диапазон дат, для которых есть данные в репозитории
+ ///
+ ///
+ ///
+ [HttpGet("range")]
+ public async Task> GetDatesRangeAsync(CancellationToken token)
+ {
+ var result = await techMessagesRepository.GetDatesRangeAsync(token);
+
+ return Ok(result);
+ }
+
+ ///
+ /// Получить порцию записей, начиная с заданной даты
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("part")]
+ public async Task>> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token)
+ {
+ var result = await techMessagesRepository.GetPart(dateBegin, take, token);
+
+ return Ok(result);
+ }
+
///
/// Добавить новые технологические сообщения
///
@@ -69,9 +106,16 @@ public class TechMessagesController : ControllerBase
///
///
[HttpPost]
- public async Task> InsertRange([FromBody] IEnumerable dtos, CancellationToken token)
+ [ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)]
+ public async Task InsertRange([FromBody] IEnumerable dtos, CancellationToken token)
{
- var result = await techMessagesRepository.InsertRange(dtos, token);
+ var userId = User.GetUserId();
+ foreach (var dto in dtos)
+ {
+ dto.UserId = userId;
+ }
+
+ var result = await techMessagesRepository.InsertRange(dtos, token);
return CreatedAtAction(nameof(InsertRange), result);
}
@@ -83,15 +127,6 @@ public class TechMessagesController : ControllerBase
[HttpGet("categories")]
public ActionResult> GetImportantCategories()
{
- var result = new Dictionary()
- {
- { 0, "System" },
- { 1, "Авария" },
- { 2, "Предупреждение" },
- { 3, "Инфо" },
- { 4, "Прочее" }
- };
-
- return Ok(result);
+ return Ok(categories);
}
-}
+}
\ No newline at end of file
diff --git a/Persistence.API/Controllers/TimeSeriesController.cs b/Persistence.API/Controllers/TimeSeriesController.cs
index a4f00f3..90c78c8 100644
--- a/Persistence.API/Controllers/TimeSeriesController.cs
+++ b/Persistence.API/Controllers/TimeSeriesController.cs
@@ -19,7 +19,7 @@ public class TimeSeriesController : ControllerBase, ITimeSeriesDataApi
- /// ,
+ /// Получить список объектов, удовлетворяющий диапазону дат
///
///
///
@@ -28,24 +28,24 @@ public class TimeSeriesController : ControllerBase, ITimeSeriesDataApi Get(DateTimeOffset dateBegin, CancellationToken token)
{
- var result = await this.timeSeriesDataRepository.GetGtDate(dateBegin, token);
+ var result = await timeSeriesDataRepository.GetGtDate(dateBegin, token);
return Ok(result);
}
///
- /// ,
+ /// Получить диапазон дат, для которых есть данные в репозиторие
///
///
///
[HttpGet("datesRange")]
public async Task GetDatesRange(CancellationToken token)
{
- var result = await this.timeSeriesDataRepository.GetDatesRange(token);
+ var result = await timeSeriesDataRepository.GetDatesRange(token);
return Ok(result);
}
///
- /// ,
+ /// Получить список объектов с прореживанием, удовлетворяющий диапазону дат
///
///
///
@@ -55,12 +55,12 @@ public class TimeSeriesController : ControllerBase, ITimeSeriesDataApi 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 timeSeriesDataRepository.GetResampledData(dateBegin, intervalSec, approxPointsCount, token);
return Ok(result);
}
///
- ///
+ /// Добавить записи
///
///
///
@@ -68,7 +68,7 @@ public class TimeSeriesController : ControllerBase, ITimeSeriesDataApi InsertRange(IEnumerable dtos, CancellationToken token)
{
- var result = await this.timeSeriesDataRepository.InsertRange(dtos, token);
+ var result = await timeSeriesDataRepository.InsertRange(dtos, token);
return Ok(result);
}
diff --git a/Persistence.Client/Clients/ISetpointClient.cs b/Persistence.Client/Clients/ISetpointClient.cs
index 72d76e1..886e034 100644
--- a/Persistence.Client/Clients/ISetpointClient.cs
+++ b/Persistence.Client/Clients/ISetpointClient.cs
@@ -19,6 +19,12 @@ public interface ISetpointClient
[Get($"{BaseRoute}/log")]
Task>>> GetLog([Query(CollectionFormat.Multi)] IEnumerable setpointKeys);
+ [Get($"{BaseRoute}/range")]
+ Task> GetDatesRangeAsync(CancellationToken token);
+
+ [Get($"{BaseRoute}/part")]
+ Task>> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token);
+
[Post($"{BaseRoute}/")]
Task Save(Guid setpointKey, object newValue);
}
diff --git a/Persistence.Client/Clients/ITechMessagesClient.cs b/Persistence.Client/Clients/ITechMessagesClient.cs
index 43839fe..cbdf7ef 100644
--- a/Persistence.Client/Clients/ITechMessagesClient.cs
+++ b/Persistence.Client/Clients/ITechMessagesClient.cs
@@ -1,5 +1,4 @@
-using Microsoft.AspNetCore.Mvc;
-using Persistence.Models;
+using Persistence.Models;
using Refit;
namespace Persistence.Client.Clients
@@ -20,7 +19,13 @@ namespace Persistence.Client.Clients
[Get($"{BaseRoute}/systems")]
Task>> GetSystems(CancellationToken token);
- [Get($"{BaseRoute}/statistics/" + "{autoDrillingSystem}")]
- Task> GetStatistics(string? autoDrillingSystem, int? importantId, CancellationToken token);
+ [Get($"{BaseRoute}/range")]
+ Task> GetDatesRangeAsync(CancellationToken token);
+
+ [Get($"{BaseRoute}/part")]
+ Task>> GetPart(DateTimeOffset dateBegin, int take, CancellationToken token);
+
+ [Get($"{BaseRoute}/statistics")]
+ Task>> GetStatistics([Query] string autoDrillingSystem, [Query] int categoryId, CancellationToken token);
}
}
diff --git a/Persistence.Client/Helpers/ApiTokenHelper.cs b/Persistence.Client/Helpers/ApiTokenHelper.cs
index e508922..5eed66e 100644
--- a/Persistence.Client/Helpers/ApiTokenHelper.cs
+++ b/Persistence.Client/Helpers/ApiTokenHelper.cs
@@ -29,8 +29,10 @@ public static class ApiTokenHelper
private static string CreateDefaultJwtToken(this AuthUser authUser)
{
+ var nameIdetifier = Guid.NewGuid().ToString();
var claims = new List()
{
+ new(ClaimTypes.NameIdentifier, nameIdetifier),
new("client_id", authUser.ClientId),
new("username", authUser.Username),
new("password", authUser.Password),
diff --git a/Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs b/Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs
index 49e438a..ea6fccf 100644
--- a/Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs
+++ b/Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs
@@ -18,7 +18,7 @@ namespace Persistence.Database.Postgres.Migrations
Key = table.Column(type: "uuid", nullable: false, comment: "Ключ"),
Created = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата изменения уставки"),
Value = table.Column