diff --git a/Persistence.API/Controllers/ChangeLogController.cs b/Persistence.API/Controllers/ChangeLogController.cs index 83a7fb6..52a68dd 100644 --- a/Persistence.API/Controllers/ChangeLogController.cs +++ b/Persistence.API/Controllers/ChangeLogController.cs @@ -22,7 +22,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpPost("{idDiscriminator}")] [ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)] public async Task Add( - [FromRoute] int idDiscriminator, + [FromRoute] Guid idDiscriminator, [FromBody] DataWithWellDepthAndSectionDto dto, CancellationToken token) { @@ -35,7 +35,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpPost("range/{idDiscriminator}")] [ProducesResponseType(typeof(int), (int)HttpStatusCode.Created)] public async Task AddRange( - [FromRoute] int idDiscriminator, + [FromRoute] Guid idDiscriminator, [FromBody] IEnumerable dtos, CancellationToken token) { @@ -68,7 +68,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpPost("replace/{idDiscriminator}")] [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] public async Task ClearAndAddRange( - [FromRoute] int idDiscriminator, + [FromRoute] Guid idDiscriminator, [FromBody] IEnumerable dtos, CancellationToken token) { @@ -104,7 +104,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("{idDiscriminator}")] [ProducesResponseType(typeof(PaginationContainer), (int)HttpStatusCode.OK)] public async Task GetCurrent( - [FromRoute] int idDiscriminator, + [FromRoute] Guid idDiscriminator, [FromQuery] SectionPartRequest filterRequest, [FromQuery] PaginationRequest paginationRequest, CancellationToken token) @@ -118,7 +118,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("moment/{idDiscriminator}")] [ProducesResponseType(typeof(PaginationContainer), (int)HttpStatusCode.OK)] public async Task GetByDate( - [FromRoute] int idDiscriminator, + [FromRoute] Guid idDiscriminator, DateTimeOffset moment, [FromQuery] SectionPartRequest filterRequest, [FromQuery] PaginationRequest paginationRequest, @@ -133,7 +133,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.NoContent)] public async Task GetChangeLogForDate( - [FromRoute] int idDiscriminator, + [FromRoute] Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) @@ -146,7 +146,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("datesChange/{idDiscriminator}")] [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.NoContent)] - public async Task GetDatesChange([FromRoute] int idDiscriminator, CancellationToken token) + public async Task GetDatesChange([FromRoute] Guid idDiscriminator, CancellationToken token) { var result = await repository.GetDatesChange(idDiscriminator, token); @@ -156,7 +156,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("part/{idDiscriminator}")] [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.NoContent)] - public async Task>> GetPart([FromRoute] int idDiscriminator, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default) + public async Task>> GetPart([FromRoute] Guid idDiscriminator, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default) { var result = await repository.GetGtDate(idDiscriminator, dateBegin, token); @@ -166,7 +166,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("datesRange/{idDiscriminator}")] [ProducesResponseType(typeof(DatesRangeDto), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.NoContent)] - public async Task> GetDatesRangeAsync([FromRoute] int idDiscriminator, CancellationToken token) + public async Task> GetDatesRangeAsync([FromRoute] Guid idDiscriminator, CancellationToken token) { var result = await repository.GetDatesRange(idDiscriminator, token); diff --git a/Persistence.API/Controllers/SetpointController.cs b/Persistence.API/Controllers/SetpointController.cs index 42a5ff5..cb8d479 100644 --- a/Persistence.API/Controllers/SetpointController.cs +++ b/Persistence.API/Controllers/SetpointController.cs @@ -97,7 +97,6 @@ public class SetpointController : ControllerBase, ISetpointApi /// /// /// - /// /// /// [HttpPost] diff --git a/Persistence.API/Controllers/WitsDataController.cs b/Persistence.API/Controllers/WitsDataController.cs index 10dd7c7..741b35c 100644 --- a/Persistence.API/Controllers/WitsDataController.cs +++ b/Persistence.API/Controllers/WitsDataController.cs @@ -28,7 +28,7 @@ public class WitsDataController : ControllerBase, IWitsDataApi /// /// [HttpGet("{discriminatorId}/datesRange")] - public async Task> GetDatesRangeAsync([FromRoute] int discriminatorId, CancellationToken token) + public async Task> GetDatesRangeAsync([FromRoute] Guid discriminatorId, CancellationToken token) { var result = await witsDataService.GetDatesRangeAsync(discriminatorId, token); @@ -44,7 +44,7 @@ public class WitsDataController : ControllerBase, IWitsDataApi /// /// [HttpGet("{discriminatorId}/part")] - public async Task>> GetPart([FromRoute] int discriminatorId, [FromQuery] DateTimeOffset dateBegin, [FromQuery] int take, CancellationToken token) + public async Task>> GetPart([FromRoute] Guid discriminatorId, [FromQuery] DateTimeOffset dateBegin, [FromQuery] int take, CancellationToken token) { var result = await witsDataService.GetPart(discriminatorId, dateBegin, take, token); @@ -61,7 +61,7 @@ public class WitsDataController : ControllerBase, IWitsDataApi /// /// [HttpGet("{discriminatorId}/graph")] - public async Task>> GetValuesForGraph([FromRoute] int discriminatorId, + public async Task>> GetValuesForGraph([FromRoute] Guid discriminatorId, [FromQuery] DateTimeOffset dateFrom, [FromQuery] DateTimeOffset dateTo, [FromQuery] int approxPointsCount, CancellationToken token) { var result = await witsDataService.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointsCount, token); diff --git a/Persistence.API/DependencyInjection.cs b/Persistence.API/DependencyInjection.cs index f6eb7e6..622a93b 100644 --- a/Persistence.API/DependencyInjection.cs +++ b/Persistence.API/DependencyInjection.cs @@ -154,7 +154,7 @@ public static class DependencyInjection { Implicit = new OpenApiOAuthFlow { - AuthorizationUrl = new Uri(configuration["Authentication:AuthorizationUrl"]), + AuthorizationUrl = new Uri(configuration["Authentication:AuthorizationUrl"]!), } } }); diff --git a/Persistence.Client/Clients/ChangeLogClient.cs b/Persistence.Client/Clients/ChangeLogClient.cs index 9cca749..00aee71 100644 --- a/Persistence.Client/Clients/ChangeLogClient.cs +++ b/Persistence.Client/Clients/ChangeLogClient.cs @@ -14,7 +14,7 @@ public class ChangeLogClient : BaseClient, IChangeLogClient this.refitChangeLogClient = refitChangeLogClient; } - public async Task ClearAndAddRange(int idDiscriminator, IEnumerable dtos, CancellationToken token) + public async Task ClearAndAddRange(Guid idDiscriminator, IEnumerable dtos, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitChangeLogClient.ClearAndAddRange(idDiscriminator, dtos, token), token); @@ -22,7 +22,7 @@ public class ChangeLogClient : BaseClient, IChangeLogClient return result; } - public async Task> GetByDate(int idDiscriminator, DateTimeOffset moment, + public async Task> GetByDate(Guid idDiscriminator, DateTimeOffset moment, SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token) { var result = await ExecuteGetResponse>( @@ -31,7 +31,7 @@ public class ChangeLogClient : BaseClient, IChangeLogClient return result; } - public async Task> GetChangeLogForInterval(int idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) + public async Task> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) { var result = await ExecuteGetResponse>( async () => await refitChangeLogClient.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token), token); @@ -39,7 +39,7 @@ public class ChangeLogClient : BaseClient, IChangeLogClient return result; } - public async Task Add(int idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token) + public async Task Add(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token) { var result = await ExecutePostResponse( async () => await refitChangeLogClient.Add(idDiscriminator, dto, token), token); @@ -47,7 +47,7 @@ public class ChangeLogClient : BaseClient, IChangeLogClient return result; } - public async Task AddRange(int idDiscriminator, IEnumerable dtos, CancellationToken token) + public async Task AddRange(Guid idDiscriminator, IEnumerable dtos, CancellationToken token) { var result = await ExecutePostResponse( async () => await refitChangeLogClient.AddRange(idDiscriminator, dtos, token), token); @@ -87,7 +87,7 @@ public class ChangeLogClient : BaseClient, IChangeLogClient return result; } - public async Task GetDatesRange(int idDiscriminator, CancellationToken token) + public async Task GetDatesRange(Guid idDiscriminator, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitChangeLogClient.GetDatesRange(idDiscriminator, token), token); diff --git a/Persistence.Client/Clients/Interfaces/IChangeLogClient.cs b/Persistence.Client/Clients/Interfaces/IChangeLogClient.cs index 501f763..0d24585 100644 --- a/Persistence.Client/Clients/Interfaces/IChangeLogClient.cs +++ b/Persistence.Client/Clients/Interfaces/IChangeLogClient.cs @@ -15,7 +15,7 @@ public interface IChangeLogClient : IDisposable /// /// /// - Task Add(int idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token); + Task Add(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token); /// /// Добавить несколько записей @@ -24,7 +24,7 @@ public interface IChangeLogClient : IDisposable /// /// /// - Task AddRange(int idDiscriminator, IEnumerable dtos, CancellationToken token); + Task AddRange(Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// /// Импорт с заменой: удаление старых строк и добавление новых @@ -33,7 +33,7 @@ public interface IChangeLogClient : IDisposable /// /// /// - Task ClearAndAddRange(int idDiscriminator, IEnumerable dtos, CancellationToken token); + Task ClearAndAddRange(Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// /// Удалить одну запись @@ -60,7 +60,7 @@ public interface IChangeLogClient : IDisposable /// /// /// - Task> GetByDate(int idDiscriminator, DateTimeOffset moment, SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token); + Task> GetByDate(Guid idDiscriminator, DateTimeOffset moment, SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token); /// /// Получение исторических данных за определенный период времени @@ -70,7 +70,7 @@ public interface IChangeLogClient : IDisposable /// /// /// - Task> GetChangeLogForInterval(int idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); + Task> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); /// /// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени) @@ -78,7 +78,7 @@ public interface IChangeLogClient : IDisposable /// /// /// - Task GetDatesRange(int idDiscriminator, CancellationToken token); + Task GetDatesRange(Guid idDiscriminator, CancellationToken token); /// /// Обновить одну запись diff --git a/Persistence.Client/Clients/Interfaces/IWitsDataClient.cs b/Persistence.Client/Clients/Interfaces/IWitsDataClient.cs index e42b5a6..e0fee60 100644 --- a/Persistence.Client/Clients/Interfaces/IWitsDataClient.cs +++ b/Persistence.Client/Clients/Interfaces/IWitsDataClient.cs @@ -17,7 +17,7 @@ public interface IWitsDataClient : IDisposable /// /// /// - Task> GetValuesForGraph(int discriminatorId, [Query] DateTimeOffset dateFrom, [Query] DateTimeOffset dateTo, [Query] int approxPointsCount, CancellationToken token); + Task> GetValuesForGraph(Guid discriminatorId, [Query] DateTimeOffset dateFrom, [Query] DateTimeOffset dateTo, [Query] int approxPointsCount, CancellationToken token); /// /// Сохранить набор параметров (Wits) @@ -35,7 +35,7 @@ public interface IWitsDataClient : IDisposable /// /// /// - Task> GetPart(int discriminatorId, [Query] DateTimeOffset dateBegin, [Query] int take = 24 * 60 * 60, CancellationToken token = default); + Task> GetPart(Guid discriminatorId, [Query] DateTimeOffset dateBegin, [Query] int take = 24 * 60 * 60, CancellationToken token = default); /// /// Получить диапазон дат, для которых есть данные в репозитории @@ -43,5 +43,5 @@ public interface IWitsDataClient : IDisposable /// /// /// - Task GetDatesRangeAsync(int discriminatorId, CancellationToken token); + Task GetDatesRangeAsync(Guid discriminatorId, CancellationToken token); } diff --git a/Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs b/Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs index a6ab9f6..c7a7bc1 100644 --- a/Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs +++ b/Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs @@ -9,24 +9,24 @@ public interface IRefitChangeLogClient : IDisposable private const string BaseRoute = "/api/ChangeLog"; [Post($"{BaseRoute}/replace/{{idDiscriminator}}")] - Task> ClearAndAddRange(int idDiscriminator, IEnumerable dtos, CancellationToken token); + Task> ClearAndAddRange(Guid idDiscriminator, IEnumerable dtos, CancellationToken token); [Get($"{BaseRoute}/moment/{{idDiscriminator}}")] Task>> GetByDate( - int idDiscriminator, + Guid idDiscriminator, DateTimeOffset moment, [Query] SectionPartRequest filterRequest, [Query] PaginationRequest paginationRequest, CancellationToken token); [Get($"{BaseRoute}/history/{{idDiscriminator}}")] - Task>> GetChangeLogForInterval(int idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); + Task>> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); [Post($"{BaseRoute}/{{idDiscriminator}}")] - Task> Add(int idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token); + Task> Add(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token); [Post($"{BaseRoute}/range/{{idDiscriminator}}")] - Task> AddRange(int idDiscriminator, IEnumerable dtos, CancellationToken token); + Task> AddRange(Guid idDiscriminator, IEnumerable dtos, CancellationToken token); [Put($"{BaseRoute}")] Task> Update(DataWithWellDepthAndSectionDto dto, CancellationToken token); @@ -41,6 +41,6 @@ public interface IRefitChangeLogClient : IDisposable Task> DeleteRange([Body] IEnumerable ids, CancellationToken token); [Get($"{BaseRoute}/datesRange/{{idDiscriminator}}")] - Task> GetDatesRange(int idDiscriminator, CancellationToken token); + Task> GetDatesRange(Guid idDiscriminator, CancellationToken token); } diff --git a/Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs b/Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs index ac7b523..c22f919 100644 --- a/Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs +++ b/Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs @@ -8,14 +8,14 @@ public interface IRefitWitsDataClient : IDisposable private const string BaseRoute = "/api/witsData"; [Get($"{BaseRoute}/{{discriminatorId}}/graph")] - Task>> GetValuesForGraph(int discriminatorId, [Query] DateTimeOffset dateFrom, [Query] DateTimeOffset dateTo, [Query] int approxPointsCount, CancellationToken token); + Task>> GetValuesForGraph(Guid discriminatorId, [Query] DateTimeOffset dateFrom, [Query] DateTimeOffset dateTo, [Query] int approxPointsCount, CancellationToken token); [Post($"{BaseRoute}/")] Task> AddRange(IEnumerable dtos, CancellationToken token); [Get($"{BaseRoute}/{{discriminatorId}}/part")] - Task>> GetPart(int discriminatorId, [Query] DateTimeOffset dateBegin, [Query] int take = 24 * 60 * 60, CancellationToken token = default); + Task>> GetPart(Guid discriminatorId, [Query] DateTimeOffset dateBegin, [Query] int take = 24 * 60 * 60, CancellationToken token = default); [Get($"{BaseRoute}/{{discriminatorId}}/datesRange")] - Task> GetDatesRangeAsync(int discriminatorId, CancellationToken token); + Task> GetDatesRangeAsync(Guid discriminatorId, CancellationToken token); } diff --git a/Persistence.Client/Clients/WitsDataClient.cs b/Persistence.Client/Clients/WitsDataClient.cs index 9aeabdf..ad58be1 100644 --- a/Persistence.Client/Clients/WitsDataClient.cs +++ b/Persistence.Client/Clients/WitsDataClient.cs @@ -22,7 +22,7 @@ public class WitsDataClient : BaseClient, IWitsDataClient return result; } - public async Task GetDatesRangeAsync(int discriminatorId, CancellationToken token) + public async Task GetDatesRangeAsync(Guid discriminatorId, CancellationToken token) { var result = await ExecuteGetResponse( async () => await refitWitsDataClient.GetDatesRangeAsync(discriminatorId, token), token); @@ -30,7 +30,7 @@ public class WitsDataClient : BaseClient, IWitsDataClient return result; } - public async Task> GetPart(int discriminatorId, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default) + public async Task> GetPart(Guid discriminatorId, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default) { var result = await ExecuteGetResponse>( async () => await refitWitsDataClient.GetPart(discriminatorId, dateBegin, take, token), token); @@ -38,7 +38,7 @@ public class WitsDataClient : BaseClient, IWitsDataClient return result; } - public async Task> GetValuesForGraph(int discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, CancellationToken token) + public async Task> GetValuesForGraph(Guid discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, CancellationToken token) { var result = await ExecuteGetResponse>( async () => await refitWitsDataClient.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointsCount, token), token); diff --git a/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs b/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs index 049e506..7e9bde6 100644 --- a/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs +++ b/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs @@ -15,7 +15,7 @@ namespace Persistence.Database.Postgres.Migrations name: "ParameterData", columns: table => new { - DiscriminatorId = table.Column(type: "integer", nullable: false, comment: "Дискриминатор системы"), + DiscriminatorId = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор системы"), ParameterId = table.Column(type: "integer", nullable: false, comment: "Id параметра"), Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"), Value = table.Column(type: "varchar(256)", nullable: false, comment: "Значение параметра в виде строки") diff --git a/Persistence.Database/Entity/ChangeLog.cs b/Persistence.Database/Entity/ChangeLog.cs index eb921aa..9a8001b 100644 --- a/Persistence.Database/Entity/ChangeLog.cs +++ b/Persistence.Database/Entity/ChangeLog.cs @@ -15,7 +15,7 @@ public class ChangeLog : IChangeLog, IWithSectionPart public Guid Id { get; set; } [Comment("Дискриминатор таблицы")] - public int IdDiscriminator { get; set; } + public Guid IdDiscriminator { get; set; } [Comment("Автор изменения")] public Guid IdAuthor { get; set; } diff --git a/Persistence.Database/Entity/IChangeLog.cs b/Persistence.Database/Entity/IChangeLog.cs index b68bb0b..c4dc962 100644 --- a/Persistence.Database/Entity/IChangeLog.cs +++ b/Persistence.Database/Entity/IChangeLog.cs @@ -39,7 +39,7 @@ public interface IChangeLog /// /// Дискриминатор таблицы /// - public int IdDiscriminator { get; set; } + public Guid IdDiscriminator { get; set; } /// /// Значение diff --git a/Persistence.Database/Entity/ParameterData.cs b/Persistence.Database/Entity/ParameterData.cs index 627bf48..f8257de 100644 --- a/Persistence.Database/Entity/ParameterData.cs +++ b/Persistence.Database/Entity/ParameterData.cs @@ -8,7 +8,7 @@ namespace Persistence.Database.Entity; public class ParameterData { [Required, Comment("Дискриминатор системы")] - public int DiscriminatorId { get; set; } + public Guid DiscriminatorId { get; set; } [Comment("Id параметра")] public int ParameterId { get; set; } diff --git a/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs b/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs index 9850550..6513e7c 100644 --- a/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs +++ b/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs @@ -29,7 +29,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest // arrange dbContext.CleanupDbSet(); - var idDiscriminator = 1; + var idDiscriminator = Guid.NewGuid(); var dtos = Generate(2, DateTimeOffset.UtcNow); // act @@ -60,7 +60,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest { // arrange var count = 1; - var idDiscriminator = 1; + var idDiscriminator = Guid.NewGuid(); var dtos = Generate(count, DateTimeOffset.UtcNow); var dto = dtos.FirstOrDefault()!; @@ -76,7 +76,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest { // arrange var count = 3; - var idDiscriminator = 1; + var idDiscriminator = Guid.NewGuid(); var dtos = Generate(count, DateTimeOffset.UtcNow); // act @@ -92,7 +92,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest // arrange dbContext.CleanupDbSet(); - var idDiscriminator = 1; + var idDiscriminator = Guid.NewGuid(); var dtos = Generate(1, DateTimeOffset.UtcNow); var dto = dtos.FirstOrDefault()!; var result = await client.Add(idDiscriminator, dto, new CancellationToken()); @@ -283,7 +283,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest var count = insertedCount; var daysRange = (daysBeforeNowChangeLog, daysAfterNowChangeLog); var changeLogItems = CreateChangeLogItems(count, daysRange); - var idDiscriminator = 1; + var idDiscriminator = changeLogItems.Item1; var entities = changeLogItems.Item2; foreach (var entity in entities) @@ -321,12 +321,12 @@ public class ChangeLogControllerTest : BaseIntegrationTest } - private (int, ChangeLog[]) CreateChangeLogItems(int count, (int, int) daysRange) + private (Guid, ChangeLog[]) CreateChangeLogItems(int count, (int, int) daysRange) { var minDayCount = daysRange.Item1; var maxDayCount = daysRange.Item2; - var idDiscriminator = 1; + var idDiscriminator = Guid.NewGuid(); var dtos = Generate(count, DateTimeOffset.UtcNow); var entities = dtos.Select(d => { diff --git a/Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs b/Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs index 32e3c83..9795a2d 100644 --- a/Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs +++ b/Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs @@ -26,7 +26,7 @@ public class WitsDataControllerTest : BaseIntegrationTest //arrange dbContext.CleanupDbSet(); - var discriminatorId = 1; + var discriminatorId = Guid.NewGuid(); //act var response = await witsDataClient.GetDatesRangeAsync(discriminatorId, CancellationToken.None); @@ -41,7 +41,7 @@ public class WitsDataControllerTest : BaseIntegrationTest //arrange dbContext.CleanupDbSet(); - var discriminatorId = 1; + var discriminatorId = Guid.NewGuid(); var dateBegin = DateTimeOffset.UtcNow; var take = 1; @@ -69,7 +69,7 @@ public class WitsDataControllerTest : BaseIntegrationTest //arrange dbContext.CleanupDbSet(); - var discriminatorId = 1; + var discriminatorId = Guid.NewGuid(); var dateFrom = DateTimeOffset.UtcNow; var dateTo = DateTimeOffset.UtcNow; var approxPointCount = 12; @@ -172,7 +172,7 @@ public class WitsDataControllerTest : BaseIntegrationTest { new WitsDataDto() { - DiscriminatorId = -1, // < 0 + DiscriminatorId = Guid.NewGuid(), Timestamped = DateTimeOffset.UtcNow, Values = new List() { @@ -201,13 +201,14 @@ public class WitsDataControllerTest : BaseIntegrationTest private async Task> AddRange(int countToCreate = 10) { var dtos = new List(); + var discriminatorId = Guid.NewGuid(); var timestamped = DateTimeOffset.UtcNow; for (var i = 0; i < countToCreate; i++) { var random = new Random(); dtos.Add(new WitsDataDto() { - DiscriminatorId = 1, + DiscriminatorId = discriminatorId, Timestamped = timestamped.AddSeconds(i), Values = new List() { diff --git a/Persistence.Repository/Repositories/ChangeLogRepository.cs b/Persistence.Repository/Repositories/ChangeLogRepository.cs index 0291c1b..dc3f5eb 100644 --- a/Persistence.Repository/Repositories/ChangeLogRepository.cs +++ b/Persistence.Repository/Repositories/ChangeLogRepository.cs @@ -16,7 +16,7 @@ public class ChangeLogRepository : IChangeLogRepository this.db = db; } - public async Task AddRange(Guid idAuthor, int idDiscriminator, IEnumerable dtos, CancellationToken token) + public async Task AddRange(Guid idAuthor, Guid idDiscriminator, IEnumerable dtos, CancellationToken token) { var entities = new List(); foreach (var dto in dtos) @@ -49,7 +49,7 @@ public class ChangeLogRepository : IChangeLogRepository return result; } - public async Task MarkAsDeleted(Guid idEditor, int idDiscriminator, CancellationToken token) + public async Task MarkAsDeleted(Guid idEditor, Guid idDiscriminator, CancellationToken token) { var query = db.Set() .Where(s => s.IdDiscriminator == idDiscriminator) @@ -75,7 +75,7 @@ public class ChangeLogRepository : IChangeLogRepository return await db.SaveChangesAsync(token); } - public async Task ClearAndAddRange(Guid idAuthor, int idDiscriminator, IEnumerable dtos, CancellationToken token) + public async Task ClearAndAddRange(Guid idAuthor, Guid idDiscriminator, IEnumerable dtos, CancellationToken token) { var result = 0; @@ -127,7 +127,7 @@ public class ChangeLogRepository : IChangeLogRepository } public async Task> GetByDate( - int idDiscriminator, + Guid idDiscriminator, DateTimeOffset momentUtc, SectionPartRequest filterRequest, PaginationRequest paginationRequest, @@ -142,14 +142,14 @@ public class ChangeLogRepository : IChangeLogRepository return result; } - private IQueryable CreateQuery(int idDiscriminator) + private IQueryable CreateQuery(Guid idDiscriminator) { var query = db.Set().Where(e => e.IdDiscriminator == idDiscriminator); return query; } - public async Task> GetChangeLogForInterval(int idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) + public async Task> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) { var query = db.Set().Where(s => s.IdDiscriminator == idDiscriminator); @@ -169,7 +169,7 @@ public class ChangeLogRepository : IChangeLogRepository - public async Task> GetDatesChange(int idDiscriminator, CancellationToken token) + public async Task> GetDatesChange(Guid idDiscriminator, CancellationToken token) { var query = db.Set().Where(e => e.IdDiscriminator == idDiscriminator); @@ -195,7 +195,7 @@ public class ChangeLogRepository : IChangeLogRepository return datesOnly; } - private ChangeLog CreateEntityFromDto(Guid idAuthor, int idDiscriminator, DataWithWellDepthAndSectionDto dto) + private ChangeLog CreateEntityFromDto(Guid idAuthor, Guid idDiscriminator, DataWithWellDepthAndSectionDto dto) { var entity = new ChangeLog() { @@ -214,7 +214,7 @@ public class ChangeLogRepository : IChangeLogRepository return entity; } - public async Task> GetGtDate(int idDiscriminator, DateTimeOffset dateBegin, CancellationToken token) + public async Task> GetGtDate(Guid idDiscriminator, DateTimeOffset dateBegin, CancellationToken token) { var date = dateBegin.ToUniversalTime(); var query = this.db.Set() @@ -228,7 +228,7 @@ public class ChangeLogRepository : IChangeLogRepository return dtos; } - public async Task GetDatesRange(int idDiscriminator, CancellationToken token) + public async Task GetDatesRange(Guid idDiscriminator, CancellationToken token) { var query = db.Set() .Where(e => e.IdDiscriminator == idDiscriminator) diff --git a/Persistence.Repository/Repositories/ParameterRepository.cs b/Persistence.Repository/Repositories/ParameterRepository.cs index dbf387f..325c08c 100644 --- a/Persistence.Repository/Repositories/ParameterRepository.cs +++ b/Persistence.Repository/Repositories/ParameterRepository.cs @@ -17,7 +17,7 @@ public class ParameterRepository : IParameterRepository protected virtual IQueryable GetQueryReadOnly() => db.Set(); - public async Task GetDatesRangeAsync(int idDiscriminator, CancellationToken token) + public async Task GetDatesRangeAsync(Guid idDiscriminator, CancellationToken token) { var query = GetQueryReadOnly() .Where(e => e.DiscriminatorId == idDiscriminator) @@ -37,7 +37,7 @@ public class ParameterRepository : IParameterRepository return result; } - public async Task> GetPart(int idDiscriminator, DateTimeOffset dateBegin, int take, CancellationToken token) + public async Task> GetPart(Guid idDiscriminator, DateTimeOffset dateBegin, int take, CancellationToken token) { var query = GetQueryReadOnly(); var universalDate = dateBegin.ToUniversalTime(); @@ -50,7 +50,7 @@ public class ParameterRepository : IParameterRepository return dtos; } - public async Task> GetValuesForGraph(int discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, + public async Task> GetValuesForGraph(Guid discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, int? ratio, CancellationToken token) { var query = db.Set().AsNoTracking(); diff --git a/Persistence.Repository/Repositories/TechMessagesRepository.cs b/Persistence.Repository/Repositories/TechMessagesRepository.cs index d2efbe4..4659da0 100644 --- a/Persistence.Repository/Repositories/TechMessagesRepository.cs +++ b/Persistence.Repository/Repositories/TechMessagesRepository.cs @@ -34,7 +34,7 @@ namespace Persistence.Repository.Repositories ? request.SortSettings : nameof(TechMessage.Timestamp); var entities = await query - .SortBy(request.SortSettings) + .SortBy(request.SortSettings!) .Skip(request.Skip) .Take(request.Take) .ToArrayAsync(token); diff --git a/Persistence/API/IChangeLogApi.cs b/Persistence/API/IChangeLogApi.cs index cbf2127..4a548bf 100644 --- a/Persistence/API/IChangeLogApi.cs +++ b/Persistence/API/IChangeLogApi.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Mvc; +using System; +using Microsoft.AspNetCore.Mvc; using Persistence.Models; using Persistence.Models.Requests; @@ -16,7 +17,7 @@ public interface IChangeLogApi : ISyncWithDiscriminatorApi /// /// - Task ClearAndAddRange(int idDiscriminator, IEnumerable dtos, CancellationToken token); + Task ClearAndAddRange(Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// /// Получение данных на текущую дату (с пагинацией) @@ -26,7 +27,7 @@ public interface IChangeLogApi : ISyncWithDiscriminatorApiпараметры запроса пагинации /// /// - Task GetCurrent(int idDiscriminator, SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token); + Task GetCurrent(Guid idDiscriminator, SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token); /// /// Получение данных на определенную дату (с пагинацией) @@ -37,7 +38,7 @@ public interface IChangeLogApi : ISyncWithDiscriminatorApiпараметры запроса пагинации /// /// - Task GetByDate(int idDiscriminator, DateTimeOffset moment, SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token); + Task GetByDate(Guid idDiscriminator, DateTimeOffset moment, SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token); /// /// Получение исторических данных за определенный период времени @@ -47,16 +48,16 @@ public interface IChangeLogApi : ISyncWithDiscriminatorApi /// /// - Task GetChangeLogForDate(int idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); + Task GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); - /// - /// Добавить одну запись - /// - /// - /// - /// - /// - Task Add(int idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token); + /// + /// Добавить одну запись + /// + /// + /// + /// + /// + Task Add(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token); /// /// Добавить несколько записей @@ -65,7 +66,7 @@ public interface IChangeLogApi : ISyncWithDiscriminatorApi /// /// - Task AddRange(int idDiscriminator, IEnumerable dtos, CancellationToken token); + Task AddRange(Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// /// Обновить одну запись @@ -105,5 +106,5 @@ public interface IChangeLogApi : ISyncWithDiscriminatorApi /// /// - Task GetDatesChange(int idDiscriminator, CancellationToken token); + Task GetDatesChange(Guid idDiscriminator, CancellationToken token); } diff --git a/Persistence/API/ISyncWithDiscriminatorApi.cs b/Persistence/API/ISyncWithDiscriminatorApi.cs index 88b49dd..224b8df 100644 --- a/Persistence/API/ISyncWithDiscriminatorApi.cs +++ b/Persistence/API/ISyncWithDiscriminatorApi.cs @@ -16,7 +16,7 @@ public interface ISyncWithDiscriminatorApi /// количество записей /// /// - Task>> GetPart(int idDiscriminator, DateTimeOffset dateBegin, int take = 24 * 60 * 60, CancellationToken token = default); + Task>> GetPart(Guid idDiscriminator, DateTimeOffset dateBegin, int take = 24 * 60 * 60, CancellationToken token = default); /// /// Получить диапазон дат, для которых есть данные в репозитории @@ -24,5 +24,5 @@ public interface ISyncWithDiscriminatorApi /// /// /// - Task> GetDatesRangeAsync(int idDiscriminator, CancellationToken token); + Task> GetDatesRangeAsync(Guid idDiscriminator, CancellationToken token); } \ No newline at end of file diff --git a/Persistence/API/IWitsDataApi.cs b/Persistence/API/IWitsDataApi.cs index 8bd3e6f..a8e5de8 100644 --- a/Persistence/API/IWitsDataApi.cs +++ b/Persistence/API/IWitsDataApi.cs @@ -17,7 +17,7 @@ public interface IWitsDataApi : ISyncWithDiscriminatorApi /// /// /// - Task>> GetValuesForGraph(int discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, + Task>> GetValuesForGraph(Guid discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, CancellationToken token); /// diff --git a/Persistence/Models/ParameterDto.cs b/Persistence/Models/ParameterDto.cs index a1155ce..63a4660 100644 --- a/Persistence/Models/ParameterDto.cs +++ b/Persistence/Models/ParameterDto.cs @@ -10,8 +10,7 @@ public class ParameterDto /// /// Дискриминатор системы /// - [Range(0, int.MaxValue, ErrorMessage = "Дискриминатор системы не может быть меньше 0")] - public int DiscriminatorId { get; set; } + public Guid DiscriminatorId { get; set; } /// /// Id параметра diff --git a/Persistence/Models/WitsDataDto.cs b/Persistence/Models/WitsDataDto.cs index 7293067..e224f6d 100644 --- a/Persistence/Models/WitsDataDto.cs +++ b/Persistence/Models/WitsDataDto.cs @@ -15,8 +15,7 @@ public class WitsDataDto /// /// Дискриминатор системы /// - [Range(0, int.MaxValue, ErrorMessage = "Дискриминатор системы не может быть меньше 0")] - public required int DiscriminatorId { get; set; } + public required Guid DiscriminatorId { get; set; } /// /// Параметры diff --git a/Persistence/Repositories/IChangeLogRepository.cs b/Persistence/Repositories/IChangeLogRepository.cs index 3db37b6..e197090 100644 --- a/Persistence/Repositories/IChangeLogRepository.cs +++ b/Persistence/Repositories/IChangeLogRepository.cs @@ -17,7 +17,7 @@ public interface IChangeLogRepository : ISyncWithDiscriminatorRepository /// /// - Task AddRange(Guid idAuthor, int idDiscriminator, IEnumerable dtos, CancellationToken token); + Task AddRange(Guid idAuthor, Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// /// Пометить записи как удаленные @@ -35,7 +35,7 @@ public interface IChangeLogRepository : ISyncWithDiscriminatorRepositoryдискриминатор таблицы /// /// - Task MarkAsDeleted(Guid idEditor, int idDiscriminator, CancellationToken token); + Task MarkAsDeleted(Guid idEditor, Guid idDiscriminator, CancellationToken token); /// /// Очистить и добавить новые @@ -45,7 +45,7 @@ public interface IChangeLogRepository : ISyncWithDiscriminatorRepository /// /// - Task ClearAndAddRange(Guid idAuthor, int idDiscriminator, IEnumerable dtos, CancellationToken token); + Task ClearAndAddRange(Guid idAuthor, Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// /// Редактирование записей @@ -65,7 +65,7 @@ public interface IChangeLogRepository : ISyncWithDiscriminatorRepositoryпараметры запроса пагинации /// /// - Task> GetByDate(int idDiscriminator, DateTimeOffset moment, SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token); + Task> GetByDate(Guid idDiscriminator, DateTimeOffset moment, SectionPartRequest filterRequest, PaginationRequest paginationRequest, CancellationToken token); /// /// Получение измененных записей за период времени @@ -75,7 +75,7 @@ public interface IChangeLogRepository : ISyncWithDiscriminatorRepository /// /// - Task> GetChangeLogForInterval(int idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); + Task> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); /// /// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени) @@ -83,5 +83,5 @@ public interface IChangeLogRepository : ISyncWithDiscriminatorRepository /// /// - Task> GetDatesChange(int idDiscriminator, CancellationToken token); + Task> GetDatesChange(Guid idDiscriminator, CancellationToken token); } diff --git a/Persistence/Repositories/IParameterRepository.cs b/Persistence/Repositories/IParameterRepository.cs index a3728da..c600898 100644 --- a/Persistence/Repositories/IParameterRepository.cs +++ b/Persistence/Repositories/IParameterRepository.cs @@ -10,14 +10,14 @@ public interface IParameterRepository /// /// /// - Task> GetPart(int idDiscriminator, DateTimeOffset dateBegin, int take, CancellationToken token); + Task> GetPart(Guid idDiscriminator, DateTimeOffset dateBegin, int take, CancellationToken token); /// /// Получить диапазон дат, для которых есть данные в репозитории /// /// /// - Task GetDatesRangeAsync(int idDiscriminator, CancellationToken token); + Task GetDatesRangeAsync(Guid idDiscriminator, CancellationToken token); /// /// Получить набор параметров (Wits) для построения графика @@ -29,7 +29,7 @@ public interface IParameterRepository /// /// /// - Task> GetValuesForGraph(int discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, + Task> GetValuesForGraph(Guid discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, int? ratio, CancellationToken token); /// diff --git a/Persistence/Repositories/ISyncWithDiscriminatorRepository.cs b/Persistence/Repositories/ISyncWithDiscriminatorRepository.cs index af8c807..7e0bd62 100644 --- a/Persistence/Repositories/ISyncWithDiscriminatorRepository.cs +++ b/Persistence/Repositories/ISyncWithDiscriminatorRepository.cs @@ -15,7 +15,7 @@ public interface ISyncWithDiscriminatorRepository /// дата начала /// /// /// - Task> GetGtDate(int idDiscriminator, DateTimeOffset dateBegin, CancellationToken token); + Task> GetGtDate(Guid idDiscriminator, DateTimeOffset dateBegin, CancellationToken token); /// @@ -24,5 +24,5 @@ public interface ISyncWithDiscriminatorRepository /// дискриминатор таблицы /// /// - Task GetDatesRange(int idDiscriminator, CancellationToken token); + Task GetDatesRange(Guid idDiscriminator, CancellationToken token); } diff --git a/Persistence/Services/Interfaces/IWitsDataService.cs b/Persistence/Services/Interfaces/IWitsDataService.cs index 69137f1..dea77ab 100644 --- a/Persistence/Services/Interfaces/IWitsDataService.cs +++ b/Persistence/Services/Interfaces/IWitsDataService.cs @@ -13,7 +13,7 @@ public interface IWitsDataService /// /// /// - Task GetDatesRangeAsync(int idDiscriminator, CancellationToken token); + Task GetDatesRangeAsync(Guid idDiscriminator, CancellationToken token); /// /// Получить порцию записей, начиная с заданной даты @@ -23,7 +23,7 @@ public interface IWitsDataService /// /// /// - Task> GetPart(int idDiscriminator, DateTimeOffset dateBegin, int take, CancellationToken token); + Task> GetPart(Guid idDiscriminator, DateTimeOffset dateBegin, int take, CancellationToken token); /// /// Получить диапазон дат, для которых есть данные в репозитории @@ -34,7 +34,7 @@ public interface IWitsDataService /// /// /// - Task> GetValuesForGraph(int discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, CancellationToken token); + Task> GetValuesForGraph(Guid discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, CancellationToken token); /// /// Сохранить набор параметров diff --git a/Persistence/Services/WitsDataService.cs b/Persistence/Services/WitsDataService.cs index e93a213..3d99a3a 100644 --- a/Persistence/Services/WitsDataService.cs +++ b/Persistence/Services/WitsDataService.cs @@ -25,14 +25,14 @@ public class WitsDataService : IWitsDataService this.witsInfo = GetWitsInfo(); } - public Task GetDatesRangeAsync(int idDiscriminator, CancellationToken token) + public Task GetDatesRangeAsync(Guid idDiscriminator, CancellationToken token) { var result = witsDataRepository.GetDatesRangeAsync(idDiscriminator, token); return result; } - public async Task> GetPart(int idDiscriminator, DateTimeOffset dateBegin, int take, CancellationToken token) + public async Task> GetPart(Guid idDiscriminator, DateTimeOffset dateBegin, int take, CancellationToken token) { var dtos = await witsDataRepository.GetPart(idDiscriminator, dateBegin, take, token); @@ -41,7 +41,7 @@ public class WitsDataService : IWitsDataService return result; } - public async Task> GetValuesForGraph(int discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, + public async Task> GetValuesForGraph(Guid discriminatorId, DateTimeOffset dateFrom, DateTimeOffset dateTo, int approxPointsCount, CancellationToken token) { var intervalSec = (dateTo - dateFrom).TotalSeconds;