diff --git a/Persistence.API/Controllers/ChangeLogController.cs b/Persistence.API/Controllers/ChangeLogController.cs index 9ce80b0..8bfa32f 100644 --- a/Persistence.API/Controllers/ChangeLogController.cs +++ b/Persistence.API/Controllers/ChangeLogController.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Persistence.Models; +using Persistence.Models.Requests; using Persistence.Repositories; namespace Persistence.API.Controllers; @@ -58,37 +59,17 @@ public class ChangeLogController : ControllerBase, IChangeLogApi return Ok(result); } - [HttpGet] - public async Task>> GetCurrent( - Guid idDiscriminator, + [HttpPost("replace")] + public async Task ClearAndInsertRange( + Guid idDiscriminator, + IEnumerable dtos, CancellationToken token) { - var date = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero); - var result = await repository.GetByDate(idDiscriminator, date, token); - + var userId = User.GetUserId(); + var result = await repository.ClearAndInsertRange(userId, idDiscriminator, dtos, token); return Ok(result); } - [HttpGet("moment")] - public async Task>> GetByDate( - Guid idDiscriminator, - DateTimeOffset moment, - CancellationToken token) - { - var result = await repository.GetByDate(idDiscriminator, moment, token); - - return Ok(result); - } - - [HttpGet("history")] - public async Task>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) - { - var result = await repository.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd, token); - - return Ok(result); - } - - [HttpPut] public async Task> Update( Guid idDiscriminator, @@ -113,5 +94,48 @@ public class ChangeLogController : ControllerBase, IChangeLogApi return Ok(result); } + [HttpGet] + public async Task>> GetCurrent( + Guid idDiscriminator, + [FromQuery]SectionPartRequest request, + CancellationToken token) + { + var moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero); + var result = await repository.GetByDate(idDiscriminator, moment, request, token); + + return Ok(result); + } + + [HttpGet("moment")] + public async Task>> GetByDate( + Guid idDiscriminator, + DateTimeOffset moment, + SectionPartRequest request, + CancellationToken token) + { + var result = await repository.GetByDate(idDiscriminator, moment, request, token); + + return Ok(result); + } + + [HttpGet("history")] + public async Task>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) + { + var result = await repository.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd, token); + + return Ok(result); + } + + [HttpGet("datesChange")] + public async Task>> GetDatesChange(Guid idDiscriminator, CancellationToken token) + { + var result = await repository.GetDatesChange(idDiscriminator, token); + + return Ok(result); + } + + + + } diff --git a/Persistence.Repository/DependencyInjection.cs b/Persistence.Repository/DependencyInjection.cs index 013f97f..7f268a3 100644 --- a/Persistence.Repository/DependencyInjection.cs +++ b/Persistence.Repository/DependencyInjection.cs @@ -1,3 +1,4 @@ +using Mapster; using Microsoft.Extensions.DependencyInjection; using Persistence.Database.Model; using Persistence.Models; @@ -10,6 +11,17 @@ public static class DependencyInjection { public static void MapsterSetup() { + TypeAdapterConfig.GlobalSettings.Default.Config + .ForType() + .Map(dest => dest.Value, src => new DataWithWellDepthAndSectionDto() + { + DepthEnd = src.DepthEnd, + DepthStart = src.DepthStart, + IdSection = src.IdSection, + Value = src.Value, + Id = src.Id + }); + } public static IServiceCollection AddInfrastructure(this IServiceCollection services) diff --git a/Persistence.Repository/Repositories/ChangeLogRepository.cs b/Persistence.Repository/Repositories/ChangeLogRepository.cs index 361a9df..5bfb870 100644 --- a/Persistence.Repository/Repositories/ChangeLogRepository.cs +++ b/Persistence.Repository/Repositories/ChangeLogRepository.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; using Persistence.Database.Model; using Persistence.Models; +using Persistence.Models.Requests; using Persistence.Repositories; namespace Persistence.Repository.Repositories; @@ -14,18 +15,46 @@ public class ChangeLogRepository : IChangeLogRepository this.db = db; } - public async Task Clear(Guid idUser, Guid idDiscriminator, CancellationToken token) + public Task InsertRange(Guid idUser, Guid idDiscriminator, IEnumerable dtos, CancellationToken token) + { + foreach (var dto in dtos) + { + var entity = CreateEntityFromDto(idUser, idDiscriminator, dto); + db.Set().Add(entity); + } + + var result = db.SaveChangesAsync(token); + + return result; + } + + public async Task MarkAsDeleted(Guid idUser, IEnumerable ids, CancellationToken token) + { + var query = db.Set().Where(s => ids.Contains(s.Id)); + var entities = await query.ToArrayAsync(token); + + var result = await Clear(idUser, entities, token); + + return result; + } + + public async Task MarkAsDeleted(Guid idUser, Guid idDiscriminator, CancellationToken token) + { + var query = db.Set() + .Where(s => s.IdDiscriminator == idDiscriminator) + .Where(e => e.Obsolete == null); + var entities = await query.ToArrayAsync(token); + + var result = await Clear(idUser, entities, token); + + return result; + } + + private async Task Clear(Guid idUser, IEnumerable entities, CancellationToken token) { var updateTime = DateTimeOffset.UtcNow; - var dbSet = db.Set(); - var query = dbSet - .Where(s => s.IdDiscriminator == idDiscriminator) - .Where(e => e.Obsolete == null); - - var entitiesToDelete = await query.ToArrayAsync(token); - - foreach (var entity in entitiesToDelete) + foreach (var entity in entities) { entity.Obsolete = updateTime; entity.IdEditor = idUser; @@ -40,7 +69,7 @@ public class ChangeLogRepository : IChangeLogRepository using var transaction = await db.Database.BeginTransactionAsync(token); try { - result += await Clear(idUser, idDiscriminator, token); + result += await MarkAsDeleted(idUser, idDiscriminator, token); result += await InsertRange(idUser, idDiscriminator, dtos, token); await transaction.CommitAsync(token); @@ -53,57 +82,154 @@ public class ChangeLogRepository : IChangeLogRepository } } - public async Task> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) + public async Task UpdateRange(Guid idUser, Guid idDiscriminator, IEnumerable dtos, CancellationToken token) { var dbSet = db.Set(); - var query = dbSet.Where(s => s.IdDiscriminator == idDiscriminator); - var min = dateBegin; - var max = dateEnd; + var updatedIds = dtos.Select(d => d.Id); + var updatedEntities = dbSet + .Where(s => updatedIds.Contains(s.Id)) + .ToDictionary(s => s.Id); + + var result = 0; + using var transaction = await db.Database.BeginTransactionAsync(token); + try + { + foreach (var dto in dtos) + { + var newEntity = CreateEntityFromDto(idUser, idDiscriminator, dto); + dbSet.Add(newEntity); + + var updatedEntity = updatedEntities.GetValueOrDefault(dto.Id)!; + updatedEntity.IdNext = newEntity.Id; + updatedEntity.Obsolete = DateTimeOffset.UtcNow; + updatedEntity.IdEditor = idUser; + } + + await db.SaveChangesAsync(token); + await transaction.CommitAsync(token); + + return result; + } + catch + { + await transaction.RollbackAsync(token); + throw; + } + } + + public async Task> GetByDate( + Guid idDiscriminator, + DateTimeOffset momentUtc, + SectionPartRequest request, + CancellationToken token) + { + var query = BuildQuery(idDiscriminator, momentUtc, request); + var result = await BuildPaginationContainer(query, request, token); + + return result; + } + + private IQueryable BuildQuery(Guid idDiscriminator, DateTimeOffset momentUtc, SectionPartRequest request) + { + var query = db.Set() + .Where(e => e.IdDiscriminator == idDiscriminator) + .Where(e => e.Creation <= momentUtc) + .Where(e => e.Obsolete == null || e.Obsolete >= momentUtc); + + if (request.IdSection.HasValue) + { + query = query.Where(e => e.IdSection == request.IdSection); + } + if (request.DepthStart.HasValue) + { + query = query.Where(e => e.DepthStart >= request.DepthStart); + } + if (request.DepthEnd.HasValue) + { + query = query.Where(e => e.DepthEnd <= request.DepthEnd); + } + + return query; + } + + public async Task> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) + { + var query = db.Set().Where(s => s.IdDiscriminator == idDiscriminator); + + var min = new DateTimeOffset(dateBegin.Year, dateBegin.Month, dateBegin.Day, 0, 0, 0, TimeSpan.Zero); + var max = new DateTimeOffset(dateEnd.Year, dateEnd.Month, dateEnd.Day, 0, 0, 0, TimeSpan.Zero); var createdQuery = query.Where(e => e.Creation >= min && e.Creation <= max); var editedQuery = query.Where(e => e.Obsolete != null && e.Obsolete >= min && e.Obsolete <= max); query = createdQuery.Union(editedQuery); - var entities = await query.ToListAsync(token); + var entities = await query.ToArrayAsync(token); - var dtos = entities.Select(e => new ChangeLogDto + var dtos = entities.Select(e => e.Adapt()); + + return dtos; + } + + + + private async Task> BuildPaginationContainer(IQueryable query, SectionPartRequest request, CancellationToken token) + { + var result = new PaginationContainer { - Creation = e.Creation, - IdAuthor = e.IdAuthor, - IdEditor = e.IdEditor, - IdNext = e.IdNext, - Obsolete = e.Obsolete, - Value = new DataWithWellDepthAndSectionDto() - { - Value = e.Value, - IdSection = e.IdSection, - Id = e.Id, - DepthEnd = e.DepthEnd, - DepthStart = e.DepthStart - } - }); + Skip = request.Skip ?? 0, + Take = request.Take ?? 32, + Items = Enumerable.Empty(), + Count = await query.CountAsync(token) + }; - return dtos; - } + if (!String.IsNullOrEmpty(request.SortSettings)) + { + query = query.SortBy(request.SortSettings); + } + else + { + query = query + .OrderBy(e => e.IdSection) + .ThenBy(e => e.DepthStart) + .ThenBy(e => e.DepthEnd); + } - public async Task> GetByDate(Guid idDiscriminator, DateTimeOffset momentUtc, CancellationToken token) - { - var dbSet = db.Set(); - var dbQuery = dbSet - .Where(s => s.IdDiscriminator == idDiscriminator) - .Where(e => e.Creation <= momentUtc) - .Where(e => e.Obsolete == null || e.Obsolete >= momentUtc); + var entities = await query + .Skip(result.Skip) + .Take(result.Take) + .ToArrayAsync(token); - var entities = await dbQuery.ToArrayAsync(token); var dtos = entities.Select(e => e.Adapt()); + result.Items = dtos; - return dtos; + return result; } - public Task> GetDatesChange(CancellationToken token) + public async Task> GetDatesChange(Guid idDiscriminator, CancellationToken token) { - throw new NotImplementedException(); + var query = db.Set().Where(e => e.IdDiscriminator == idDiscriminator); + + var datesCreateQuery = query + .Select(e => e.Creation) + .Distinct(); + + var datesCreate = await datesCreateQuery.ToArrayAsync(token); + + var datesUpdateQuery = query + .Where(e => e.Obsolete != null) + .Select(e => e.Obsolete!.Value) + .Distinct(); + + var datesUpdate = await datesUpdateQuery.ToArrayAsync(token); + + var dates = Enumerable.Concat(datesCreate, datesUpdate); + var datesOnly = dates + .Select(d => new DateOnly(d.Year, d.Month, d.Day)) + .Distinct() + .OrderBy(d => d); + + return datesOnly; } public Task>> GetGtDate(DateTimeOffset dateBegin, CancellationToken token) @@ -111,19 +237,6 @@ public class ChangeLogRepository : IChangeLogRepository throw new NotImplementedException(); } - public Task InsertRange(Guid idUser, Guid idDiscriminator, IEnumerable dtos, CancellationToken token) - { - foreach (var dto in dtos) - { - var entity = CreateEntityFromDto(idUser, idDiscriminator, dto); - db.Set().Add(entity); - } - - var result = db.SaveChangesAsync(token); - - return result; - } - private ChangeLog CreateEntityFromDto(Guid idUser, Guid idDiscriminator, DataWithWellDepthAndSectionDto dto) { var entity = new ChangeLog() @@ -143,52 +256,4 @@ public class ChangeLogRepository : IChangeLogRepository return entity; } - public async Task MarkAsDeleted(Guid idUser, IEnumerable ids, CancellationToken token) - { - var result = 0; - var dbSet = db.Set(); - - var updatedEntity = dbSet - .Where(s => ids.Contains(s.Id)) - .FirstOrDefault(); - if (updatedEntity != null) - { - updatedEntity.Obsolete = DateTimeOffset.UtcNow; - - result = await db.SaveChangesAsync(token); - } - - return result; - } - - public Task UpdateOrInsertRange(int idUser, IEnumerable> dtos, CancellationToken token) - { - throw new NotImplementedException(); - } - - public async Task UpdateRange(Guid idUser, Guid idDiscriminator, IEnumerable dtos, CancellationToken token) - { - var dbSet = db.Set(); - - var updatedIds = dtos.Select(d => d.Id); - var updatedEntities = dbSet - .Where(s => updatedIds.Contains(s.Id)) - .ToDictionary(s => s.Id); - //todo - foreach (var dto in dtos) - { - var newEntity = CreateEntityFromDto(idUser, idDiscriminator, dto); - dbSet.Add(newEntity); - - var updatedEntity = updatedEntities.GetValueOrDefault(dto.Id)!; - updatedEntity.IdNext = newEntity.Id; - updatedEntity.Obsolete = DateTimeOffset.UtcNow; - updatedEntity.IdEditor = idUser; - - } - - var result = await db.SaveChangesAsync(token); - - return result; - } } diff --git a/Persistence/API/IChangeLogApi.cs b/Persistence/API/IChangeLogApi.cs index 5419e2d..a0f75a0 100644 --- a/Persistence/API/IChangeLogApi.cs +++ b/Persistence/API/IChangeLogApi.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Persistence.Models; +using Persistence.Models.Requests; namespace Persistence.API; @@ -9,21 +10,32 @@ namespace Persistence.API; public interface IChangeLogApi { /// - /// Получение данных на текущую дату + /// Импорт с заменой: удаление старых строк и добавление новых /// /// + /// /// /// - Task>> GetCurrent(Guid idDiscriminator, CancellationToken token); + Task ClearAndInsertRange(Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// - /// Получение данных на определенную дату + /// Получение данных на текущую дату (с пагинацией) + /// + /// + /// параметры запроса + /// + /// + Task>> GetCurrent(Guid idDiscriminator, SectionPartRequest request, CancellationToken token); + + /// + /// Получение данных на определенную дату (с пагинацией) /// /// /// + /// параметры запроса /// /// - Task>> GetByDate(Guid idDiscriminator, DateTimeOffset moment, CancellationToken token); + Task>> GetByDate(Guid idDiscriminator, DateTimeOffset moment, SectionPartRequest request, CancellationToken token); /// /// Получение исторических данных за определенный период времени @@ -86,4 +98,12 @@ public interface IChangeLogApi /// /// Task> DeleteRange(IEnumerable ids, CancellationToken token); + + /// + /// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени) + /// + /// + /// + /// + Task>> GetDatesChange(Guid idDiscriminator, CancellationToken token); } diff --git a/Persistence/API/ITableDataApi.cs b/Persistence/API/ITableDataApi.cs index a310799..075559a 100644 --- a/Persistence/API/ITableDataApi.cs +++ b/Persistence/API/ITableDataApi.cs @@ -1,17 +1,13 @@ using Microsoft.AspNetCore.Mvc; using Persistence.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Persistence.Models.Requests; namespace Persistence.API; /// Интерфейс для API, предназначенного для работы с табличными данными public interface ITableDataApi where TDto : class, new() - where TRequest : RequestDto + where TRequest : Request { /// /// Получить страницу списка объектов diff --git a/Persistence/EFExtensions.cs b/Persistence/EFExtensions.cs new file mode 100644 index 0000000..00474cc --- /dev/null +++ b/Persistence/EFExtensions.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace Persistence; +public static class EFExtensions +{ + struct TypeAcessor + { + public LambdaExpression KeySelector { get; set; } + public MethodInfo OrderBy { get; set; } + public MethodInfo OrderByDescending { get; set; } + public MethodInfo ThenBy { get; set; } + public MethodInfo ThenByDescending { get; set; } + } + private static readonly MethodInfo methodOrderBy = GetExtOrderMethod("OrderBy"); + + private static readonly MethodInfo methodOrderByDescending = GetExtOrderMethod("OrderByDescending"); + + private static readonly MethodInfo methodThenBy = GetExtOrderMethod("ThenBy"); + + private static readonly MethodInfo methodThenByDescending = GetExtOrderMethod("ThenByDescending"); + private static ConcurrentDictionary> TypePropSelectors { get; set; } = new(); + + private static MethodInfo GetExtOrderMethod(string methodName) + => typeof(System.Linq.Queryable) + .GetMethods() + .Where(m => m.Name == methodName && + m.IsGenericMethodDefinition && + m.GetParameters().Length == 2 && + m.GetParameters()[1].ParameterType.IsAssignableTo(typeof(LambdaExpression))) + .Single(); + private static Dictionary MakeTypeAcessors(Type type) + { + var propContainer = new Dictionary(); + var properties = type.GetProperties(); + foreach (var propertyInfo in properties) + { + var name = propertyInfo.Name.ToLower(); + ParameterExpression arg = Expression.Parameter(type, "x"); + MemberExpression property = Expression.Property(arg, propertyInfo.Name); + var selector = Expression.Lambda(property, new ParameterExpression[] { arg }); + var typeAccessor = new TypeAcessor + { + KeySelector = selector, + OrderBy = methodOrderBy.MakeGenericMethod(type, propertyInfo.PropertyType), + OrderByDescending = methodOrderByDescending.MakeGenericMethod(type, propertyInfo.PropertyType), + ThenBy = methodThenBy.MakeGenericMethod(type, propertyInfo.PropertyType), + ThenByDescending = methodThenByDescending.MakeGenericMethod(type, propertyInfo.PropertyType), + }; + + propContainer.Add(name, typeAccessor); + } + return propContainer; + } + + /// + /// Добавить в запрос сортировку по возрастанию или убыванию. + /// Этот метод сбросит ранее наложенные сортировки. + /// + /// + /// + /// + /// Свойство сортировки. + /// Состоит из названия свойства (в любом регистре) + /// и опционально указания направления сортировки "asc" или "desc" + /// + /// + /// var query = query("Date desc"); + /// + /// Запрос с примененной сортировкой + public static IOrderedQueryable SortBy( + this IQueryable query, + string propertySort) + { + var parts = propertySort.Split(" ", 2, StringSplitOptions.RemoveEmptyEntries); + var isDesc = parts.Length >= 2 && parts[1].ToLower().Trim() == "desc"; + var propertyName = parts[0]; + + var newQuery = query.SortBy(propertyName, isDesc); + return newQuery; + } + + /// + /// Добавить в запрос сортировку по возрастанию или убыванию + /// + /// + /// + /// Название свойства (в любом регистре) + /// Сортировать по убыванию + /// Запрос с примененной сортировкой + public static IOrderedQueryable SortBy( + this IQueryable query, + string propertyName, + bool isDesc) + { + var typePropSelector = TypePropSelectors.GetOrAdd(typeof(TSource), MakeTypeAcessors); + var propertyNamelower = propertyName.ToLower(); + var typeAccessor = typePropSelector[propertyNamelower]; + + var genericMethod = isDesc + ? typeAccessor.OrderByDescending + : typeAccessor.OrderBy; + + var newQuery = (IOrderedQueryable)genericMethod + .Invoke(genericMethod, new object[] { query, typeAccessor.KeySelector })!; + return newQuery; + } +} diff --git a/Persistence/Models/RequestDto.cs b/Persistence/Models/Requests/Request.cs similarity index 58% rename from Persistence/Models/RequestDto.cs rename to Persistence/Models/Requests/Request.cs index c61ac79..a53f5a9 100644 --- a/Persistence/Models/RequestDto.cs +++ b/Persistence/Models/Requests/Request.cs @@ -1,23 +1,25 @@ -namespace Persistence.Models; +namespace Persistence.Models.Requests; /// /// Контейнер для поддержки постраничного просмотра таблиц /// /// -public class RequestDto +public class Request { /// /// Кол-во записей пропущенных с начала таблицы в запросе от api /// - public int Skip { get; set; } + public int? Skip { get; set; } /// /// Кол-во записей в запросе от api /// - public int Take { get; set; } + public int? Take { get; set; } /// - /// Настройки сортировки + /// Сортировки: + /// Содержат список названий полей сортировки + /// Указать направление сортировки можно через пробел "asc" или "desc" /// public string SortSettings { get; set; } = string.Empty; } diff --git a/Persistence/Models/Requests/SectionPartRequest.cs b/Persistence/Models/Requests/SectionPartRequest.cs new file mode 100644 index 0000000..a05082d --- /dev/null +++ b/Persistence/Models/Requests/SectionPartRequest.cs @@ -0,0 +1,22 @@ +namespace Persistence.Models.Requests; + +/// +/// Запрос для фильтрации данных по секции и глубине +/// +public class SectionPartRequest : Request +{ + /// + /// Глубина забоя на дату начала интервала + /// + public double? DepthStart { get; set; } + + /// + /// Глубина забоя на дату окончания интервала + /// + public double? DepthEnd { get; set; } + + /// + /// Ключ секции + /// + public Guid? IdSection { get; set; } +} diff --git a/Persistence/Repositories/IChangeLogRepository.cs b/Persistence/Repositories/IChangeLogRepository.cs index ab4f4a9..b5cd53a 100644 --- a/Persistence/Repositories/IChangeLogRepository.cs +++ b/Persistence/Repositories/IChangeLogRepository.cs @@ -1,4 +1,5 @@ using Persistence.Models; +using Persistence.Models.Requests; namespace Persistence.Repositories; @@ -19,31 +20,22 @@ public interface IChangeLogRepository //: ISyncRepository Task InsertRange(Guid idUser, Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// - /// Редактирование записей - /// - /// пользователь, который редактирует - /// - /// - /// - /// - Task UpdateRange(Guid idUser, Guid idDiscriminator, IEnumerable dtos, CancellationToken token); - - /// - /// Добавляет Dto у которых id == 0, изменяет dto у которых id != 0 - /// - /// пользователь, который редактирует или добавляет - /// - /// - /// - Task UpdateOrInsertRange(int idUser, IEnumerable> dtos, CancellationToken token); - - /// - /// Помечает записи как удаленные + /// Пометить записи как удаленные /// /// + /// ключи записей /// /// - Task Clear(Guid idUser, Guid idDiscriminator, CancellationToken token); + Task MarkAsDeleted(Guid idUser, IEnumerable ids, CancellationToken token); + + /// + /// Пометить записи как удаленные + /// + /// + /// дискриминатор таблицы + /// + /// + Task MarkAsDeleted(Guid idUser, Guid idDiscriminator, CancellationToken token); /// /// Очистить и добавить новые @@ -56,21 +48,24 @@ public interface IChangeLogRepository //: ISyncRepository Task ClearAndInsertRange(Guid idUser, Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// - /// Пометить записи как удаленные + /// Редактирование записей /// - /// - /// + /// пользователь, который редактирует + /// + /// /// /// - Task MarkAsDeleted(Guid idUser, IEnumerable ids, CancellationToken token); + Task UpdateRange(Guid idUser, Guid idDiscriminator, IEnumerable dtos, CancellationToken token); /// - /// Получение дат изменений записей + /// Получение актуальных записей на определенный момент времени (с пагинацией) /// - /// + /// + /// текущий момент времени + /// параметры запроса /// /// - Task> GetDatesChange(CancellationToken token); + Task> GetByDate(Guid idDiscriminator, DateTimeOffset moment, SectionPartRequest request, CancellationToken token); /// /// Получение измененных записей за период времени @@ -83,11 +78,10 @@ public interface IChangeLogRepository //: ISyncRepository Task> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); /// - /// Получение актуальных записей на определенный момент времени + /// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени) /// /// - /// текущий момент времени /// /// - Task> GetByDate(Guid idDiscriminator, DateTimeOffset moment, CancellationToken token); + Task> GetDatesChange(Guid idDiscriminator, CancellationToken token); } diff --git a/Persistence/Repositories/ITableDataRepository.cs b/Persistence/Repositories/ITableDataRepository.cs index 73d332d..574ff76 100644 --- a/Persistence/Repositories/ITableDataRepository.cs +++ b/Persistence/Repositories/ITableDataRepository.cs @@ -1,4 +1,4 @@ -using Persistence.Models; +using Persistence.Models.Requests; namespace Persistence.Repositories; @@ -7,7 +7,7 @@ namespace Persistence.Repositories; /// public interface ITableDataRepository where TDto : class, new() - where TRequest : RequestDto + where TRequest : Request { /// /// Получить страницу списка объектов