From 4ccbe4361a31fcbce596e7cc18b24a6c0ca23f07 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: Mon, 9 Dec 2024 10:15:17 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ChangeLogController.cs | 25 +++++++++++-------- Persistence.Repository/QueryBuilders.cs | 6 +++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Persistence.API/Controllers/ChangeLogController.cs b/Persistence.API/Controllers/ChangeLogController.cs index 54a3b0c..cad59c4 100644 --- a/Persistence.API/Controllers/ChangeLogController.cs +++ b/Persistence.API/Controllers/ChangeLogController.cs @@ -37,7 +37,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi public async Task AddRange( [FromRoute] Guid idDiscriminator, [FromBody] IEnumerable dtos, - CancellationToken token = default) + CancellationToken token) { var userId = User.GetUserId(); var result = await repository.AddRange(userId, idDiscriminator, dtos, token); @@ -47,7 +47,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpDelete] [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] - public async Task Delete(Guid id, CancellationToken token = default) + public async Task Delete(Guid id, CancellationToken token) { var userId = User.GetUserId(); var result = await repository.MarkAsDeleted(userId, [id], token); @@ -57,7 +57,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpDelete("range")] [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] - public async Task DeleteRange(IEnumerable ids, CancellationToken token = default) + public async Task DeleteRange(IEnumerable ids, CancellationToken token) { var userId = User.GetUserId(); var result = await repository.MarkAsDeleted(userId, ids, token); @@ -70,7 +70,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi public async Task ClearAndAddRange( [FromRoute] Guid idDiscriminator, [FromBody] IEnumerable dtos, - CancellationToken token = default) + CancellationToken token) { var userId = User.GetUserId(); var result = await repository.ClearAndAddRange(userId, idDiscriminator, dtos, token); @@ -81,7 +81,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] public async Task Update( DataWithWellDepthAndSectionDto dto, - CancellationToken token = default) + CancellationToken token) { var userId = User.GetUserId(); var result = await repository.UpdateRange(userId, [dto], token); @@ -93,7 +93,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [ProducesResponseType(typeof(int), (int)HttpStatusCode.OK)] public async Task UpdateRange( IEnumerable dtos, - CancellationToken token = default) + CancellationToken token) { var userId = User.GetUserId(); var result = await repository.UpdateRange(userId, dtos, token); @@ -107,7 +107,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [FromRoute] Guid idDiscriminator, [FromQuery] SectionPartRequest filterRequest, [FromQuery] PaginationRequest paginationRequest, - CancellationToken token = default) + CancellationToken token) { var moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero); var result = await repository.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token); @@ -122,7 +122,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi DateTimeOffset moment, [FromQuery] SectionPartRequest filterRequest, [FromQuery] PaginationRequest paginationRequest, - CancellationToken token = default) + CancellationToken token) { var result = await repository.GetByDate(idDiscriminator, moment, filterRequest, paginationRequest, token); @@ -131,11 +131,12 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("history/{idDiscriminator}")] [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] + [ProducesResponseType((int)HttpStatusCode.NoContent)] public async Task GetChangeLogForDate( [FromRoute] Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, - CancellationToken token = default) + CancellationToken token) { var result = await repository.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token); @@ -144,7 +145,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("datesChange/{idDiscriminator}")] [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] - public async Task GetDatesChange([FromRoute] Guid idDiscriminator, CancellationToken token = default) + [ProducesResponseType((int)HttpStatusCode.NoContent)] + public async Task GetDatesChange([FromRoute] Guid idDiscriminator, CancellationToken token) { var result = await repository.GetDatesChange(idDiscriminator, token); @@ -153,6 +155,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi [HttpGet("part/{idDiscriminator}")] [ProducesResponseType(typeof(IEnumerable), (int)HttpStatusCode.OK)] + [ProducesResponseType((int)HttpStatusCode.NoContent)] public async Task GetPart([FromRoute] Guid idDiscriminator, DateTimeOffset dateBegin, int take = 86400, CancellationToken token = default) { var result = await repository.GetGtDate(idDiscriminator, dateBegin, token); @@ -163,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] Guid idDiscriminator, CancellationToken token = default) + public async Task GetDatesRangeAsync([FromRoute] Guid idDiscriminator, CancellationToken token) { var result = await repository.GetDatesRange(idDiscriminator, token); diff --git a/Persistence.Repository/QueryBuilders.cs b/Persistence.Repository/QueryBuilders.cs index 9ed98e5..6070a8a 100644 --- a/Persistence.Repository/QueryBuilders.cs +++ b/Persistence.Repository/QueryBuilders.cs @@ -67,12 +67,14 @@ public static class QueryBuilders .Take(request.Take) .ToArrayAsync(token); + var count = await query.CountAsync(token); + var items = entities.Select(Convert); var result = new PaginationContainer { Skip = request.Skip, Take = request.Take, - Items = entities.Select(Convert), - Count = await query.CountAsync(token) + Items = items, + Count = count }; return result;