ChangeLog репозиторий
This commit is contained in:
parent
5094f4556d
commit
a3d90e05f7
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Persistence.Database.Model;
|
|
||||||
using Persistence.Models;
|
using Persistence.Models;
|
||||||
using Persistence.Repositories;
|
using Persistence.Repositories;
|
||||||
|
|
||||||
@ -20,8 +19,8 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ActionResult<int>> Add(
|
public async Task<ActionResult<int>> Add(
|
||||||
[FromRoute] Guid idDiscriminator,
|
Guid idDiscriminator,
|
||||||
ChangeLogDto dto,
|
[FromBody] DataWithWellDepthAndSectionDto dto,
|
||||||
CancellationToken token)
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
var userId = User.GetUserId<Guid>();
|
var userId = User.GetUserId<Guid>();
|
||||||
@ -31,50 +30,88 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("range")]
|
[HttpPost("range")]
|
||||||
public Task<ActionResult<int>> AddRange(IEnumerable<IDictionary<string, object>> dtos, CancellationToken token)
|
public async Task<ActionResult<int>> AddRange(
|
||||||
|
Guid idDiscriminator,
|
||||||
|
[FromBody] IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var userId = User.GetUserId<Guid>();
|
||||||
|
var result = await repository.InsertRange(userId, idDiscriminator, dtos, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public Task<ActionResult<int>> Delete(int id, CancellationToken token)
|
public async Task<ActionResult<int>> Delete(Guid id, CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var userId = User.GetUserId<Guid>();
|
||||||
|
var result = await repository.MarkAsDeleted(userId, [id], token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("range")]
|
[HttpDelete("range")]
|
||||||
public Task<ActionResult<int>> DeleteRange(IEnumerable<int> ids, CancellationToken token)
|
public async Task<ActionResult<int>> DeleteRange(IEnumerable<Guid> ids, CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var userId = User.GetUserId<Guid>();
|
||||||
|
var result = await repository.MarkAsDeleted(userId, ids, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public Task<ActionResult<IEnumerable<IDictionary<string, object>>>> GetChangeLogCurrent(CancellationToken token)
|
public async Task<ActionResult<IEnumerable<DataWithWellDepthAndSectionDto>>> GetCurrent(
|
||||||
|
Guid idDiscriminator,
|
||||||
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var date = new DateTimeOffset(3000, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
||||||
|
var result = await repository.GetByDate(idDiscriminator, date, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("moment")]
|
||||||
|
public async Task<ActionResult<IEnumerable<DataWithWellDepthAndSectionDto>>> GetByDate(
|
||||||
|
Guid idDiscriminator,
|
||||||
|
DateTimeOffset moment,
|
||||||
|
CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = await repository.GetByDate(idDiscriminator, moment, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("history")]
|
[HttpGet("history")]
|
||||||
public Task<ActionResult<IEnumerable<ChangeLogDto>>> GetChangeLogForDate(DateTimeOffset historyMoment, CancellationToken token)
|
public async Task<ActionResult<IEnumerable<ChangeLogDto>>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var result = await repository.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
//[HttpGet("history")]
|
|
||||||
//public Task<ActionResult<IEnumerable<ChangeLogDto<IDictionary<string, object>>>>> GetChangeLogForDate(DateTimeOffset historyMoment, CancellationToken token)
|
|
||||||
//{
|
|
||||||
// throw new NotImplementedException();
|
|
||||||
//}
|
|
||||||
|
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
public Task<ActionResult<int>> Update(IDictionary<string, object> dto, CancellationToken token)
|
public async Task<ActionResult<int>> Update(
|
||||||
|
Guid idDiscriminator,
|
||||||
|
DataWithWellDepthAndSectionDto dto,
|
||||||
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var userId = User.GetUserId<Guid>();
|
||||||
|
var result = await repository.UpdateRange(userId, idDiscriminator, [dto], token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("range")]
|
[HttpPut("range")]
|
||||||
public Task<ActionResult<int>> UpdateRange(IEnumerable<IDictionary<string, object>> dtos, CancellationToken token)
|
public async Task<ActionResult<int>> UpdateRange(
|
||||||
|
Guid idDiscriminator,
|
||||||
|
IEnumerable<DataWithWellDepthAndSectionDto> dtos,
|
||||||
|
CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var userId = User.GetUserId<Guid>();
|
||||||
|
var result = await repository.UpdateRange(userId, idDiscriminator, dtos, token);
|
||||||
|
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
|
||||||
|
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.2.1" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -22,6 +22,7 @@ public class Startup
|
|||||||
services.AddSwagger(Configuration);
|
services.AddSwagger(Configuration);
|
||||||
services.AddInfrastructure();
|
services.AddInfrastructure();
|
||||||
services.AddPersistenceDbContext(Configuration);
|
services.AddPersistenceDbContext(Configuration);
|
||||||
|
services.AddAuthorization();
|
||||||
services.AddJWTAuthentication(Configuration);
|
services.AddJWTAuthentication(Configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +39,9 @@ public class Startup
|
|||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
@ -14,24 +14,91 @@ public class ChangeLogRepository : IChangeLogRepository
|
|||||||
this.db = db;
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> Clear(int idUser, CancellationToken token)
|
public async Task<int> Clear(Guid idUser, Guid idDiscriminator, CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var updateTime = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
|
var dbSet = db.Set<ChangeLog>();
|
||||||
|
var query = dbSet
|
||||||
|
.Where(s => s.IdDiscriminator == idDiscriminator)
|
||||||
|
.Where(e => e.Obsolete == null);
|
||||||
|
|
||||||
|
var entitiesToDelete = await query.ToArrayAsync(token);
|
||||||
|
|
||||||
|
foreach (var entity in entitiesToDelete)
|
||||||
|
{
|
||||||
|
entity.Obsolete = updateTime;
|
||||||
|
entity.IdEditor = idUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> ClearAndInsertRange(int idUser, IEnumerable<IDictionary<string, object>> dtos, CancellationToken token)
|
return await db.SaveChangesAsync(token);
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IEnumerable<ChangeLogDto>> GetChangeLogForDate(DateTimeOffset? updateFrom, CancellationToken token)
|
public async Task<int> ClearAndInsertRange(Guid idUser, Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var result = 0;
|
||||||
|
using var transaction = await db.Database.BeginTransactionAsync(token);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result += await Clear(idUser, idDiscriminator, token);
|
||||||
|
result += await InsertRange(idUser, idDiscriminator, dtos, token);
|
||||||
|
|
||||||
|
await transaction.CommitAsync(token);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
await transaction.RollbackAsync(token);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IEnumerable<IDictionary<string, object>>> GetCurrent(DateTimeOffset moment, CancellationToken token)
|
public async Task<IEnumerable<ChangeLogDto>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var dbSet = db.Set<ChangeLog>();
|
||||||
|
var query = dbSet.Where(s => s.IdDiscriminator == idDiscriminator);
|
||||||
|
|
||||||
|
var min = dateBegin;
|
||||||
|
var max = dateEnd;
|
||||||
|
|
||||||
|
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 dtos = entities.Select(e => new ChangeLogDto
|
||||||
|
{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<DataWithWellDepthAndSectionDto>> GetByDate(Guid idDiscriminator, DateTimeOffset momentUtc, CancellationToken token)
|
||||||
|
{
|
||||||
|
var dbSet = db.Set<ChangeLog>();
|
||||||
|
var dbQuery = dbSet
|
||||||
|
.Where(s => s.IdDiscriminator == idDiscriminator)
|
||||||
|
.Where(e => e.Creation <= momentUtc)
|
||||||
|
.Where(e => e.Obsolete == null || e.Obsolete >= momentUtc);
|
||||||
|
|
||||||
|
var entities = await dbQuery.ToArrayAsync(token);
|
||||||
|
var dtos = entities.Select(e => e.Adapt<DataWithWellDepthAndSectionDto>());
|
||||||
|
|
||||||
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IEnumerable<DateOnly>> GetDatesChange(CancellationToken token)
|
public Task<IEnumerable<DateOnly>> GetDatesChange(CancellationToken token)
|
||||||
@ -44,36 +111,54 @@ public class ChangeLogRepository : IChangeLogRepository
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> InsertRange(Guid idUser, Guid idDiscriminator, IEnumerable<ChangeLogDto> dtos, CancellationToken token)
|
public Task<int> InsertRange(Guid idUser, Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entities = new List<ChangeLog>();
|
|
||||||
foreach (var dto in dtos)
|
foreach (var dto in dtos)
|
||||||
{
|
{
|
||||||
var entity = new ChangeLog()
|
var entity = CreateEntityFromDto(idUser, idDiscriminator, dto);
|
||||||
{
|
db.Set<ChangeLog>().Add(entity);
|
||||||
IdAuthor = idUser,
|
|
||||||
IdDiscriminator = idDiscriminator,
|
|
||||||
IdEditor = idUser,
|
|
||||||
Value = dto.Value,
|
|
||||||
Creation = DateTimeOffset.UtcNow,
|
|
||||||
IdSection = dto.IdSection,
|
|
||||||
DepthStart = dto.DepthStart,
|
|
||||||
DepthEnd = dto.DepthEnd,
|
|
||||||
};
|
|
||||||
entity.Id = idUser;
|
|
||||||
|
|
||||||
entities.Add(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db.Set<ChangeLog>().AddRange(entities);
|
|
||||||
var result = db.SaveChangesAsync(token);
|
var result = db.SaveChangesAsync(token);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> MarkAsDeleted(int idUser, IEnumerable<int> ids, CancellationToken token)
|
private ChangeLog CreateEntityFromDto(Guid idUser, Guid idDiscriminator, DataWithWellDepthAndSectionDto dto)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var entity = new ChangeLog()
|
||||||
|
{
|
||||||
|
Id = default,
|
||||||
|
Creation = DateTimeOffset.UtcNow,
|
||||||
|
IdAuthor = idUser,
|
||||||
|
IdDiscriminator = idDiscriminator,
|
||||||
|
IdEditor = idUser,
|
||||||
|
|
||||||
|
Value = dto.Value,
|
||||||
|
IdSection = dto.IdSection,
|
||||||
|
DepthStart = dto.DepthStart,
|
||||||
|
DepthEnd = dto.DepthEnd,
|
||||||
|
};
|
||||||
|
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> MarkAsDeleted(Guid idUser, IEnumerable<Guid> ids, CancellationToken token)
|
||||||
|
{
|
||||||
|
var result = 0;
|
||||||
|
var dbSet = db.Set<ChangeLog>();
|
||||||
|
|
||||||
|
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<int> UpdateOrInsertRange(int idUser, IEnumerable<IDictionary<string, object>> dtos, CancellationToken token)
|
public Task<int> UpdateOrInsertRange(int idUser, IEnumerable<IDictionary<string, object>> dtos, CancellationToken token)
|
||||||
@ -81,8 +166,29 @@ public class ChangeLogRepository : IChangeLogRepository
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> UpdateRange(int idUser, IEnumerable<IDictionary<string, object>> dtos, CancellationToken token)
|
public async Task<int> UpdateRange(Guid idUser, Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
var dbSet = db.Set<ChangeLog>();
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,51 +9,67 @@ namespace Persistence.API;
|
|||||||
public interface IChangeLogApi
|
public interface IChangeLogApi
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение исторических данных на текущую дату
|
/// Получение данных на текущую дату
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="idDiscriminator"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<IEnumerable<IDictionary<string, object>>>> GetChangeLogCurrent(CancellationToken token);
|
Task<ActionResult<IEnumerable<DataWithWellDepthAndSectionDto>>> GetCurrent(Guid idDiscriminator, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение исторических данных на определенную дату
|
/// Получение данных на определенную дату
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="historyMoment"></param>
|
/// <param name="idDiscriminator"></param>
|
||||||
|
/// <param name="moment"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<IEnumerable<ChangeLogDto>>> GetChangeLogForDate(DateTimeOffset historyMoment, CancellationToken token);
|
Task<ActionResult<IEnumerable<DataWithWellDepthAndSectionDto>>> GetByDate(Guid idDiscriminator, DateTimeOffset moment, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение исторических данных за определенный период времени
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idDiscriminator"></param>
|
||||||
|
/// <param name="dateBegin"></param>
|
||||||
|
/// <param name="dateEnd"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<ActionResult<IEnumerable<ChangeLogDto>>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить одну запись
|
/// Добавить одну запись
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="idDiscriminator"></param>
|
||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> Add(Guid idDiscriminator, ChangeLogDto dto, CancellationToken token);
|
Task<ActionResult<int>> Add(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить несколько записей
|
/// Добавить несколько записей
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="idDiscriminator"></param>
|
||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> AddRange(IEnumerable<IDictionary<string, object>> dtos, CancellationToken token);
|
Task<ActionResult<int>> AddRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновить одну запись
|
/// Обновить одну запись
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="idDiscriminator"></param>
|
||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> Update(IDictionary<string, object> dto, CancellationToken token);
|
Task<ActionResult<int>> Update(Guid idDiscriminator, DataWithWellDepthAndSectionDto dto, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновить несколько записей
|
/// Обновить несколько записей
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="idDiscriminator"></param>
|
||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> UpdateRange(IEnumerable<IDictionary<string, object>> dtos, CancellationToken token);
|
Task<ActionResult<int>> UpdateRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить одну запись
|
/// Удалить одну запись
|
||||||
@ -61,7 +77,7 @@ public interface IChangeLogApi
|
|||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> Delete(int id, CancellationToken token);
|
Task<ActionResult<int>> Delete(Guid id, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить несколько записей
|
/// Удалить несколько записей
|
||||||
@ -69,5 +85,5 @@ public interface IChangeLogApi
|
|||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> DeleteRange(IEnumerable<int> ids, CancellationToken token);
|
Task<ActionResult<int>> DeleteRange(IEnumerable<Guid> ids, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,6 @@ public class ChangeLogDto
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создатель записи
|
/// Создатель записи
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -40,23 +35,8 @@ public class ChangeLogDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Guid? IdNext { get; set; }
|
public Guid? IdNext { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Глубина забоя на дату начала интервала
|
|
||||||
/// </summary>
|
|
||||||
public double DepthStart { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Глубина забоя на дату окончания интервала
|
|
||||||
/// </summary>
|
|
||||||
public double DepthEnd { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ключ секции
|
|
||||||
/// </summary>
|
|
||||||
public Guid IdSection { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Объект записи
|
/// Объект записи
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public required IDictionary<string, object> Value { get; set; }
|
public DataWithWellDepthAndSectionDto Value { get; set; }
|
||||||
}
|
}
|
||||||
|
43
Persistence/Models/DataWithWellDepthAndSectionDto.cs
Normal file
43
Persistence/Models/DataWithWellDepthAndSectionDto.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Persistence.Models;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dto для хранения записей, содержащих начальную и конечную глубину забоя, а также секцию
|
||||||
|
/// </summary>
|
||||||
|
public class DataWithWellDepthAndSectionDto
|
||||||
|
{
|
||||||
|
public DataWithWellDepthAndSectionDto()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ключ записи
|
||||||
|
/// </summary>
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Глубина забоя на дату начала интервала
|
||||||
|
/// </summary>
|
||||||
|
public double DepthStart { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Глубина забоя на дату окончания интервала
|
||||||
|
/// </summary>
|
||||||
|
public double DepthEnd { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ключ секции
|
||||||
|
/// </summary>
|
||||||
|
public Guid IdSection { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Объект записи
|
||||||
|
/// </summary>
|
||||||
|
public required IDictionary<string, object> Value { get; set; } = default!;
|
||||||
|
}
|
@ -16,16 +16,17 @@ public interface IChangeLogRepository //: ISyncRepository<TDto>
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> InsertRange(Guid idUser, Guid idDiscriminator, IEnumerable<ChangeLogDto> dtos, CancellationToken token);
|
Task<int> InsertRange(Guid idUser, Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Редактирование записей
|
/// Редактирование записей
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idUser">пользователь, который редактирует</param>
|
/// <param name="idUser">пользователь, который редактирует</param>
|
||||||
|
/// <param name="idDiscriminator"></param>
|
||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> UpdateRange(int idUser, IEnumerable<IDictionary<string, object>> dtos, CancellationToken token);
|
Task<int> UpdateRange(Guid idUser, Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавляет Dto у которых id == 0, изменяет dto у которых id != 0
|
/// Добавляет Dto у которых id == 0, изменяет dto у которых id != 0
|
||||||
@ -39,19 +40,20 @@ public interface IChangeLogRepository //: ISyncRepository<TDto>
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Помечает записи как удаленные
|
/// Помечает записи как удаленные
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idUser">пользователь, который чистит</param>
|
/// <param name="idUser"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> Clear(int idUser, CancellationToken token);
|
Task<int> Clear(Guid idUser, Guid idDiscriminator, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Очистить и добавить новые
|
/// Очистить и добавить новые
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idUser"></param>
|
/// <param name="idUser"></param>
|
||||||
|
/// <param name="idDiscriminator"></param>
|
||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> ClearAndInsertRange(int idUser, IEnumerable<IDictionary<string, object>> dtos, CancellationToken token);
|
Task<int> ClearAndInsertRange(Guid idUser, Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Пометить записи как удаленные
|
/// Пометить записи как удаленные
|
||||||
@ -60,7 +62,7 @@ public interface IChangeLogRepository //: ISyncRepository<TDto>
|
|||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> MarkAsDeleted(int idUser, IEnumerable<int> ids, CancellationToken token);
|
Task<int> MarkAsDeleted(Guid idUser, IEnumerable<Guid> ids, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение дат изменений записей
|
/// Получение дат изменений записей
|
||||||
@ -71,18 +73,21 @@ public interface IChangeLogRepository //: ISyncRepository<TDto>
|
|||||||
Task<IEnumerable<DateOnly>> GetDatesChange(CancellationToken token);
|
Task<IEnumerable<DateOnly>> GetDatesChange(CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение измененных записей за определенную дату
|
/// Получение измененных записей за период времени
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="updateFrom"></param>
|
/// <param name="idDiscriminator"></param>
|
||||||
|
/// <param name="dateBegin"></param>
|
||||||
|
/// <param name="dateEnd"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<ChangeLogDto>> GetChangeLogForDate(DateTimeOffset? updateFrom, CancellationToken token);
|
Task<IEnumerable<ChangeLogDto>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение текущих сейчас записей по параметрам
|
/// Получение актуальных записей на определенный момент времени
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="idDiscriminator"></param>
|
||||||
|
/// <param name="moment">текущий момент времени</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<IDictionary<string, object>>> GetCurrent(DateTimeOffset moment, CancellationToken token);
|
Task<IEnumerable<DataWithWellDepthAndSectionDto>> GetByDate(Guid idDiscriminator, DateTimeOffset moment, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user