From ca816da076ff15b18b258efed638258888d47daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Tue, 3 Dec 2024 17:36:41 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82?= =?UTF-8?q?=D0=B0=D0=BC=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E=20(=D1=87=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D0=B8=D1=87=D0=BD=D0=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ChangeLogController.cs | 2 +- .../Clients/IChangeLogClient.cs | 3 +- .../Controllers/ChangeLogControllerTest.cs | 6 +-- .../Repositories/ChangeLogRepository.cs | 6 +-- Persistence/Models/ChangeLogDto.cs | 2 +- .../Models/DataWithWellDepthAndSectionDto.cs | 7 +--- Persistence/Models/IChangeLogDto.cs | 42 ------------------- Persistence/Models/ProcessMapRotorDto.cs | 11 ----- Persistence/Models/Requests/Request.cs | 6 +-- .../Repositories/IChangeLogRepository.cs | 2 +- 10 files changed, 14 insertions(+), 73 deletions(-) delete mode 100644 Persistence/Models/IChangeLogDto.cs delete mode 100644 Persistence/Models/ProcessMapRotorDto.cs diff --git a/Persistence.API/Controllers/ChangeLogController.cs b/Persistence.API/Controllers/ChangeLogController.cs index bc66a16..a698b87 100644 --- a/Persistence.API/Controllers/ChangeLogController.cs +++ b/Persistence.API/Controllers/ChangeLogController.cs @@ -137,7 +137,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi DateTimeOffset dateEnd, CancellationToken token = default) { - var result = await repository.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd, token); + var result = await repository.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token); return Ok(result); } diff --git a/Persistence.Client/Clients/IChangeLogClient.cs b/Persistence.Client/Clients/IChangeLogClient.cs index e904057..74807cc 100644 --- a/Persistence.Client/Clients/IChangeLogClient.cs +++ b/Persistence.Client/Clients/IChangeLogClient.cs @@ -11,7 +11,6 @@ public interface IChangeLogClient { private const string BaseRoute = "/api/ChangeLog"; - //[Get($"{BaseRoute}/current")] /// /// Импорт с заменой: удаление старых строк и добавление новых /// @@ -39,7 +38,7 @@ public interface IChangeLogClient /// /// [Get($"{BaseRoute}/history")] - Task>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd); + Task>> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd); /// /// Добавить одну запись diff --git a/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs b/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs index 39ea3f8..ea47c6a 100644 --- a/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs +++ b/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs @@ -97,7 +97,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest var dateBegin = DateTimeOffset.UtcNow.AddDays(-1); var dateEnd = DateTimeOffset.UtcNow.AddDays(1); - var changeLogResult = await client.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd); + var changeLogResult = await client.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd); Assert.Equal(HttpStatusCode.OK, changeLogResult.StatusCode); Assert.NotNull(changeLogResult.Content); @@ -254,7 +254,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest [Theory] [InlineData(5, -15, 15, -20, 20, 10)] [InlineData(5, -15, -10, -16, -9, 5)] - public async Task GetChangeLogForDate_returns_success( + public async Task GetChangeLogForInterval_returns_success( int insertedCount, int leftCreationFromCurrentDate, int rightCreationFromCurrentDate, @@ -280,7 +280,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest //act var dateBegin = DateTimeOffset.UtcNow.AddDays(leftPointFromCurrentDate); var dateEnd = DateTimeOffset.UtcNow.AddDays(rightPointFromCurrentDate); - var result = await client.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd); + var result = await client.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd); //assert Assert.Equal(HttpStatusCode.OK, result.StatusCode); diff --git a/Persistence.Repository/Repositories/ChangeLogRepository.cs b/Persistence.Repository/Repositories/ChangeLogRepository.cs index 514fed5..09c304a 100644 --- a/Persistence.Repository/Repositories/ChangeLogRepository.cs +++ b/Persistence.Repository/Repositories/ChangeLogRepository.cs @@ -153,7 +153,7 @@ public class ChangeLogRepository : IChangeLogRepository return query; } - public async Task> GetChangeLogForDate(Guid 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); @@ -177,8 +177,8 @@ public class ChangeLogRepository : IChangeLogRepository { var result = new PaginationContainer { - Skip = request.Skip ?? 0, - Take = request.Take ?? 32, + Skip = request.Skip, + Take = request.Take, Items = Enumerable.Empty(), Count = await query.CountAsync(token) }; diff --git a/Persistence/Models/ChangeLogDto.cs b/Persistence/Models/ChangeLogDto.cs index 8e28874..ba3ff5c 100644 --- a/Persistence/Models/ChangeLogDto.cs +++ b/Persistence/Models/ChangeLogDto.cs @@ -36,7 +36,7 @@ public class ChangeLogDto public DateTimeOffset? Obsolete { get; set; } /// - /// Ключ следующей записи + /// Ключ заменившей записи /// public Guid? IdNext { get; set; } diff --git a/Persistence/Models/DataWithWellDepthAndSectionDto.cs b/Persistence/Models/DataWithWellDepthAndSectionDto.cs index b3747c2..7939dd0 100644 --- a/Persistence/Models/DataWithWellDepthAndSectionDto.cs +++ b/Persistence/Models/DataWithWellDepthAndSectionDto.cs @@ -11,11 +11,6 @@ namespace Persistence.Models; /// public class DataWithWellDepthAndSectionDto { - public DataWithWellDepthAndSectionDto() - { - - } - /// /// Ключ записи /// @@ -39,5 +34,5 @@ public class DataWithWellDepthAndSectionDto /// /// Объект записи /// - public required IDictionary Value { get; set; } = default!; + public required IDictionary Value { get; set; } } diff --git a/Persistence/Models/IChangeLogDto.cs b/Persistence/Models/IChangeLogDto.cs deleted file mode 100644 index 09cfd09..0000000 --- a/Persistence/Models/IChangeLogDto.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Persistence.Models; - -/// -/// Часть записи описывающая изменение -/// -public interface IChangeLogDto -{ - ///// - ///// Ид записи - ///// - //public int Id { get; set; } - - ///// - ///// Автор изменения - ///// - //public int IdAuthor { get; set; } - - ///// - ///// Редактор - ///// - //public int? IdEditor { get; set; } - - ///// - ///// Дата создания записи - ///// - //public DateTimeOffset Creation { get; set; } - - ///// - ///// Дата устаревания (например при удалении) - ///// - //public DateTimeOffset? Obsolete { get; set; } - - ///// - ///// Id заменяющей записи - ///// - //public int? IdNext { get; set; } - - ///// - ///// Значение - ///// - //public object Value { get; set; } -} diff --git a/Persistence/Models/ProcessMapRotorDto.cs b/Persistence/Models/ProcessMapRotorDto.cs deleted file mode 100644 index 316f07a..0000000 --- a/Persistence/Models/ProcessMapRotorDto.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Persistence.Models; -public class ProcessMapRotorDto : IChangeLogDto -{ - public string Caption { get; set; } -} diff --git a/Persistence/Models/Requests/Request.cs b/Persistence/Models/Requests/Request.cs index c1b0583..30dd38a 100644 --- a/Persistence/Models/Requests/Request.cs +++ b/Persistence/Models/Requests/Request.cs @@ -9,17 +9,17 @@ public class Request /// /// Кол-во записей пропущенных с начала таблицы в запросе от api /// - public int? Skip { get; set; } + public int Skip { get; set; } = 0; /// /// Кол-во записей в запросе от api /// - public int? Take { get; set; } + public int Take { get; set; } = 32; /// /// Сортировки: /// Содержат список названий полей сортировки /// Указать направление сортировки можно через пробел "asc" или "desc" /// - public string? SortSettings { get; set; } = string.Empty; + public string? SortSettings { get; set; } } diff --git a/Persistence/Repositories/IChangeLogRepository.cs b/Persistence/Repositories/IChangeLogRepository.cs index c885c90..2d668cc 100644 --- a/Persistence/Repositories/IChangeLogRepository.cs +++ b/Persistence/Repositories/IChangeLogRepository.cs @@ -75,7 +75,7 @@ public interface IChangeLogRepository : ISyncWithDiscriminatorRepository /// /// - Task> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); + Task> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); /// /// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени)