forked from ddrilling/AsbCloudServer
правки
This commit is contained in:
parent
d414fad58c
commit
459fc3acb8
@ -11,7 +11,7 @@ namespace AsbCloudApp.Repositories;
|
||||
/// Репозиторий для записей с историей
|
||||
/// </summary>
|
||||
public interface IChangeLogRepository<TDto, TRequest>
|
||||
where TDto : AsbCloudApp.Data.IId
|
||||
where TDto : IId
|
||||
{
|
||||
/// <summary>
|
||||
/// Добавление записей
|
||||
@ -83,7 +83,7 @@ public interface IChangeLogRepository<TDto, TRequest>
|
||||
/// <param name="date">Фильтр по дате. Если null - вернет все записи, без привязки к дате</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ChangeLogDto<TDto>>> GetChangeLog(TRequest request, DateOnly? date, CancellationToken token);
|
||||
Task<IEnumerable<ChangeLogDto<TDto>>> GetChangeLogForDate(TRequest request, DateOnly? date, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение текущих сейчас записей по параметрам
|
||||
@ -92,4 +92,13 @@ public interface IChangeLogRepository<TDto, TRequest>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<TDto>> GetCurrent(TRequest request, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение измененных записей за определенный момент времени
|
||||
/// </summary>
|
||||
/// <param name="changeLogRequest">фильтр по changeLog</param>
|
||||
/// <param name="dataRequest">фильтр по данным внутри changeLog</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ChangeLogDto<TDto>>> GetChangeLogByMoment(ChangeLogRequest changeLogRequest, TRequest dataRequest, CancellationToken token);
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace AsbCloudApp.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Базовый запрос актуальных данных
|
||||
/// Запрос изменений
|
||||
/// </summary>
|
||||
public class ChangeLogBaseRequest
|
||||
public class ChangeLogRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Дата/время на которую записи были актуальны. Если не задано, то возвращаются все данные без учета их актуальности
|
||||
@ -15,7 +15,7 @@ public class ChangeLogBaseRequest
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public ChangeLogBaseRequest()
|
||||
public ChangeLogRequest()
|
||||
{
|
||||
|
||||
}
|
||||
@ -24,7 +24,7 @@ public class ChangeLogBaseRequest
|
||||
/// Копирующий конструктор
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
public ChangeLogBaseRequest(ChangeLogBaseRequest request)
|
||||
public ChangeLogRequest(ChangeLogRequest request)
|
||||
{
|
||||
Moment = request.Moment;
|
||||
}
|
@ -5,7 +5,7 @@ namespace AsbCloudApp.Requests;
|
||||
/// <summary>
|
||||
/// Запрос для получения РТК план
|
||||
/// </summary>
|
||||
public class ProcessMapPlanBaseRequest : ChangeLogBaseRequest
|
||||
public class ProcessMapPlanBaseRequest : ChangeLogRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Вернуть данные, которые поменялись с указанной даты
|
||||
|
@ -17,7 +17,7 @@ namespace AsbCloudInfrastructure.Repository;
|
||||
public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : IChangeLogRepository<TDto, TRequest>
|
||||
where TDto : AsbCloudApp.Data.IId
|
||||
where TEntity : ChangeLogAbstract
|
||||
where TRequest : ChangeLogBaseRequest
|
||||
where TRequest : ChangeLogRequest
|
||||
{
|
||||
protected readonly IAsbCloudDbContext db;
|
||||
|
||||
@ -218,7 +218,7 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
||||
return datesOnly;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ChangeLogDto<TDto>>> GetChangeLog(TRequest request, DateOnly? date, CancellationToken token)
|
||||
public async Task<IEnumerable<ChangeLogDto<TDto>>> GetChangeLogForDate(TRequest request, DateOnly? date, CancellationToken token)
|
||||
{
|
||||
var query = BuildQuery(request);
|
||||
TimeSpan offset = GetTimezoneOffset(request);
|
||||
@ -251,18 +251,18 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ChangeLogDto<TDto>>> Get(TRequest request, DateTimeOffset? moment, CancellationToken token)
|
||||
public async Task<IEnumerable<ChangeLogDto<TDto>>> GetChangeLogByMoment(ChangeLogRequest changeLogRequest, TRequest dataRequest, CancellationToken token)
|
||||
{
|
||||
var query = BuildQuery(request);
|
||||
if (moment.HasValue)
|
||||
var query = BuildQuery(dataRequest);
|
||||
if (changeLogRequest.Moment.HasValue)
|
||||
{
|
||||
var momentUtc = moment.Value.ToUniversalTime();
|
||||
var momentUtc = changeLogRequest.Moment.Value.ToUniversalTime();
|
||||
query = query
|
||||
.Where(e => e.Creation <= momentUtc)
|
||||
.Where(e => e.Obsolete == null || e.Obsolete >= momentUtc);
|
||||
}
|
||||
|
||||
TimeSpan offset = GetTimezoneOffset(request);
|
||||
TimeSpan offset = GetTimezoneOffset(dataRequest);
|
||||
var dtos = await CreateChangeLogDto(query, offset, token);
|
||||
|
||||
return dtos;
|
||||
@ -270,8 +270,11 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
||||
|
||||
public async Task<IEnumerable<TDto>> GetCurrent(TRequest request, CancellationToken token)
|
||||
{
|
||||
var moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
||||
var entities = await Get(request, moment, token);
|
||||
var changeLogRequest = new ChangeLogRequest()
|
||||
{
|
||||
Moment = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero)
|
||||
};
|
||||
var entities = await GetChangeLogByMoment(changeLogRequest, request, token);
|
||||
var result = entities.Select(e => e.Item);
|
||||
return result;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
||||
|
||||
var requestProcessMapPlan = new ProcessMapPlanBaseRequestWithWell(idWell);
|
||||
var changeLogProcessMaps = await processMapPlanBaseRepository.GetChangeLog(requestProcessMapPlan, null, token);
|
||||
var changeLogProcessMaps = await processMapPlanBaseRepository.GetChangeLogForDate(requestProcessMapPlan, null, token);
|
||||
|
||||
if (!changeLogProcessMaps.Any())
|
||||
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
||||
|
@ -155,10 +155,10 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
/// <param name="moment"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("history")]
|
||||
[HttpGet("changelogByMoment")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> GetHistory([FromRoute] int idWell, DateTimeOffset? moment, CancellationToken token)
|
||||
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> GetChangeLogByMoment([FromRoute] int idWell, DateTimeOffset? moment, CancellationToken token)
|
||||
{
|
||||
await AssertUserHasAccessToWell(idWell, token);
|
||||
|
||||
@ -167,7 +167,12 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
Moment = moment,
|
||||
};
|
||||
|
||||
var result = await repository.GetChangeLog(serviceRequest, null, token);
|
||||
var changeLogRequest = new ChangeLogRequest()
|
||||
{
|
||||
Moment = moment
|
||||
};
|
||||
|
||||
var result = await repository.GetChangeLogByMoment(changeLogRequest, serviceRequest, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
@ -194,7 +199,7 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
UpdateFrom = updateFrom,
|
||||
};
|
||||
|
||||
var result = await repository.GetChangeLog(serviceRequest, null, token);
|
||||
var result = await repository.GetChangeLogForDate(serviceRequest, null, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
@ -205,15 +210,15 @@ public abstract class ProcessMapPlanBaseController<TDto> : ControllerBase
|
||||
/// <param name="date"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("changeLog")]
|
||||
[HttpGet("changeLogForDate")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> GetChangeLog([FromRoute] int idWell, [FromQuery] DateOnly? date, CancellationToken token)
|
||||
public async Task<ActionResult<IEnumerable<ChangeLogDto<TDto>>>> GetChangeLogForDate([FromRoute] int idWell, [FromQuery] DateOnly? date, CancellationToken token)
|
||||
{
|
||||
await AssertUserHasAccessToWell(idWell, token);
|
||||
|
||||
var serviceRequest = new ProcessMapPlanBaseRequestWithWell(idWell);
|
||||
var result = await repository.GetChangeLog(serviceRequest, date, token);
|
||||
var result = await repository.GetChangeLogForDate(serviceRequest, date, token);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user