Убран параметр TRequest

This commit is contained in:
Olga Nemt 2024-11-02 12:05:12 +05:00
parent 49c9a6107b
commit 65e2cb0977
4 changed files with 32 additions and 34 deletions

View File

@ -17,34 +17,36 @@ public abstract class AbstractChangeLogRepository<TEntity, TChangeLogDto, TDto>
}
public abstract TEntity Convert(TDto entity);
public async Task<int> Clear(int idUser, TRequest request, CancellationToken token)
public async Task<int> Clear(int idUser,CancellationToken token)
{
var updateTime = DateTimeOffset.UtcNow;
throw new NotImplementedException();
//todo
var query = BuildQuery(request);
query = query.Where(e => e.Obsolete == null);
//var updateTime = DateTimeOffset.UtcNow;
var entitiesToDelete = await query.ToArrayAsync(token);
////todo
//var query = BuildQuery(request);
//query = query.Where(e => e.Obsolete == null);
foreach (var entity in entitiesToDelete)
{
entity.IdState = IChangeLogAbstract.IdCleared;
entity.Obsolete = updateTime;
entity.IdEditor = idUser;
//var entitiesToDelete = await query.ToArrayAsync(token);
//foreach (var entity in entitiesToDelete)
//{
// entity.IdState = IChangeLogAbstract.IdCleared;
// entity.Obsolete = updateTime;
// entity.IdEditor = idUser;
//}
//var result = await SaveChangesWithExceptionHandling(token);
//return result;
}
var result = await SaveChangesWithExceptionHandling(token);
return result;
}
public async Task<int> ClearAndInsertRange(int idUser, TRequest request, IEnumerable<TDto> dtos, CancellationToken token)
public async Task<int> ClearAndInsertRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
{
var result = 0;
using var transaction = await dbContext.Database.BeginTransactionAsync(token);
try
{
result += await Clear(idUser, request, token);
result += await Clear(idUser, token);
result += await InsertRangeWithoutTransaction(idUser, dtos, token);
await transaction.CommitAsync(token);
@ -57,12 +59,12 @@ public abstract class AbstractChangeLogRepository<TEntity, TChangeLogDto, TDto>
}
}
public Task<IEnumerable<TDto>> GetCurrent(TRequest request, CancellationToken token)
public Task<IEnumerable<TDto>> GetCurrent(DateTimeOffset moment, CancellationToken token)
{
throw new NotImplementedException();
}
public Task<IEnumerable<DateOnly>> GetDatesChange(TRequest request, CancellationToken token)
public Task<IEnumerable<DateOnly>> GetDatesChange(CancellationToken token)
{
throw new NotImplementedException();
}
@ -74,9 +76,7 @@ public abstract class AbstractChangeLogRepository<TEntity, TChangeLogDto, TDto>
public async Task<int> InsertRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
{
this.dbContext.Set<TEntity>();
var db = GetDataBase();
using var transaction = db.BeginTransaction();
using var transaction = dbContext.Database.BeginTransaction();
try
{
var result = await InsertRangeWithoutTransaction(idUser, dtos, token);
@ -107,7 +107,7 @@ public abstract class AbstractChangeLogRepository<TEntity, TChangeLogDto, TDto>
throw new NotImplementedException();
}
public Task<IEnumerable<TChangeLogDto>> GetChangeLogForDate(TRequest request, DateOnly? date, CancellationToken token)
public Task<IEnumerable<TChangeLogDto>> GetChangeLogForDate(DateTimeOffset? updateFrom, CancellationToken token)
{
throw new NotImplementedException();
}

View File

@ -3,11 +3,12 @@
namespace Persistence.Repositories;
/// <summary>
///
/// Интерфейс для работы с историческими данными
/// </summary>
/// <typeparam name="TDto"></typeparam>
public interface IChangeLogRepository<TDto, TChangeLogDto> : ISyncRepository<TDto>
where TDto : class
where TChangeLogDto : ChangeLogDto<TDto>
{
/// <summary>
/// Добавление записей
@ -40,20 +41,18 @@ public interface IChangeLogRepository<TDto, TChangeLogDto> : ISyncRepository<TDt
/// Помечает записи как удаленные
/// </summary>
/// <param name="idUser">пользователь, который чистит</param>
/// <param name="request">Фильтр по свойствам конкретной сущности</param>
/// <param name="token"></param>
/// <returns></returns>
Task<int> Clear(int idUser, TRequest request, CancellationToken token);
Task<int> Clear(int idUser, CancellationToken token);
/// <summary>
/// Очистить и добавить новые
/// </summary>
/// <param name="idUser"></param>
/// <param name="request"></param>
/// <param name="dtos"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<int> ClearAndInsertRange(int idUser, TRequest request, IEnumerable<TDto> dtos, CancellationToken token);
Task<int> ClearAndInsertRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token);
/// <summary>
/// Пометить записи как удаленные
@ -70,16 +69,15 @@ public interface IChangeLogRepository<TDto, TChangeLogDto> : ISyncRepository<TDt
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<DateOnly>> GetDatesChange(TRequest request, CancellationToken token);
Task<IEnumerable<DateOnly>> GetDatesChange(CancellationToken token);
/// <summary>
/// Получение измененных записей за определенную дату
/// </summary>
/// <param name="request"></param>
/// <param name="date">Фильтр по дате. Если null - вернет все записи, без привязки к дате</param>
/// <param name="updateFrom"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<TChangeLogDto>> GetChangeLogForDate(TRequest request, DateOnly? date, CancellationToken token);
Task<IEnumerable<TChangeLogDto>> GetChangeLogForDate(DateTimeOffset? updateFrom, CancellationToken token);
/// <summary>
/// Получение текущих сейчас записей по параметрам
@ -87,5 +85,5 @@ public interface IChangeLogRepository<TDto, TChangeLogDto> : ISyncRepository<TDt
/// <param name="request"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IEnumerable<TDto>> GetCurrent(TRequest request, CancellationToken token);
Task<IEnumerable<TDto>> GetCurrent(DateTimeOffset moment, CancellationToken token);
}

View File

@ -1,7 +1,7 @@
namespace Persistence.Repositories;
/// <summary>
///
/// Интерфейс по работе с данными
/// </summary>
/// <typeparam name="TDto"></typeparam>
public interface ISyncRepository<TDto>

View File

@ -1,7 +1,7 @@
namespace Persistence.Repositories;
/// <summary>
///
/// Интерфейс по работе с временными данными
/// </summary>
/// <typeparam name="T"></typeparam>
public interface ITimeSeriesDataRepository<TDto> : ISyncRepository<TDto>