Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
32a41fcd80 |
68
Persistence.API/Controllers/ChangeLogController.cs
Normal file
68
Persistence.API/Controllers/ChangeLogController.cs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Persistence.Models;
|
||||||
|
using Persistence.Repositories;
|
||||||
|
|
||||||
|
namespace Persistence.API.Controllers
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class ChangeLogController<TDto, TChangeLogDto> : ControllerBase, IChangeLogApi<TDto, TChangeLogDto>
|
||||||
|
where TDto : class, IChangeLogAbstract, new()
|
||||||
|
where TChangeLogDto : ChangeLogDto<TDto>
|
||||||
|
{
|
||||||
|
private IChangeLogRepository<TDto, TChangeLogDto> changeLogRepository;
|
||||||
|
|
||||||
|
public ChangeLogController(IChangeLogRepository<TDto, TChangeLogDto> changeLogRepository)
|
||||||
|
{
|
||||||
|
this.changeLogRepository = changeLogRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public Task<ActionResult<IEnumerable<TDto>>> GetChangeLogCurrent(CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("forDate")]
|
||||||
|
public Task<ActionResult<IEnumerable<TChangeLogDto>>> GetChangeLogForDate(DateTimeOffset historyMoment, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public Task<ActionResult<int>> AddAsync(TDto dto, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public Task<ActionResult<int>> AddRangeAsync(IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public Task<ActionResult<int>> DeleteAsync(int id, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public Task<ActionResult<int>> DeleteRangeAsync(IEnumerable<int> ids, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("update")]
|
||||||
|
public Task<ActionResult<int>> UpdateAsync(TDto dto, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("update")]
|
||||||
|
public Task<ActionResult<int>> UpdateRangeAsync(IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
Persistence.Database/Model/ChangeLog.cs
Normal file
22
Persistence.Database/Model/ChangeLog.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Persistence.Database.Model
|
||||||
|
{
|
||||||
|
public class ChangeLog : IChangeLogData
|
||||||
|
{
|
||||||
|
[Column("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Column("idnext")]
|
||||||
|
public int? IdNext { get; set; }
|
||||||
|
|
||||||
|
[Column("idprevious")]
|
||||||
|
public int? IdPrevious { get; set; }
|
||||||
|
|
||||||
|
[Column("creation")]
|
||||||
|
public DateTimeOffset Creation { get; set; }
|
||||||
|
|
||||||
|
[Column("obsolete")]
|
||||||
|
public DateTimeOffset? Obsolete { get; set; }
|
||||||
|
}
|
||||||
|
}
|
11
Persistence.Database/Model/IChangeLogData.cs
Normal file
11
Persistence.Database/Model/IChangeLogData.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace Persistence.Database.Model
|
||||||
|
{
|
||||||
|
internal interface IChangeLogData
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int? IdNext { get; set; }
|
||||||
|
public int? IdPrevious { get; set; }
|
||||||
|
public DateTimeOffset Creation { get; set; }
|
||||||
|
public DateTimeOffset? Obsolete { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ namespace Persistence.Database.Model;
|
|||||||
public interface IPersistenceDbContext : IDisposable
|
public interface IPersistenceDbContext : IDisposable
|
||||||
{
|
{
|
||||||
DbSet<DataSaub> DataSaub { get; }
|
DbSet<DataSaub> DataSaub { get; }
|
||||||
|
DbSet<ChangeLog> ChangeLog { get; }
|
||||||
DatabaseFacade Database { get; }
|
DatabaseFacade Database { get; }
|
||||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.Metrics;
|
using System.Diagnostics.Metrics;
|
||||||
@ -10,9 +10,12 @@ using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
|||||||
namespace Persistence.Database.Model;
|
namespace Persistence.Database.Model;
|
||||||
public partial class PersistenceDbContext : DbContext, IPersistenceDbContext
|
public partial class PersistenceDbContext : DbContext, IPersistenceDbContext
|
||||||
{
|
{
|
||||||
public DbSet<DataSaub> DataSaub => Set<DataSaub>();
|
public DbSet<DataSaub> DataSaub => Set<DataSaub>();
|
||||||
|
public DbSet<ChangeLog> ChangeLog => Set<ChangeLog>();
|
||||||
|
|
||||||
public PersistenceDbContext(DbContextOptions<PersistenceDbContext> options)
|
public PersistenceDbContext() { } // Áåç ïóñòîãî êîíñòðóêòîðà ìèãðàöèÿ ïàäààåò
|
||||||
|
|
||||||
|
public PersistenceDbContext(DbContextOptions<PersistenceDbContext> options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
Persistence.Repository/Data/LogDto.cs
Normal file
16
Persistence.Repository/Data/LogDto.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Persistence.Models;
|
||||||
|
|
||||||
|
namespace Persistence.Repository.Data
|
||||||
|
{
|
||||||
|
internal class LogDto : IChangeLogAbstract
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int IdAuthor { get; set; }
|
||||||
|
public int? IdNext { get; set; }
|
||||||
|
public int? IdPrevious { get; set; }
|
||||||
|
public int? IdEditor { get; set; }
|
||||||
|
public int IdState { get; set; }
|
||||||
|
public DateTimeOffset Creation { get; set; }
|
||||||
|
public DateTimeOffset? Obsolete { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ using Persistence.Repositories;
|
|||||||
using Persistence.Database.Model;
|
using Persistence.Database.Model;
|
||||||
using Persistence.Repository.Data;
|
using Persistence.Repository.Data;
|
||||||
using Persistence.Repository.Repositories;
|
using Persistence.Repository.Repositories;
|
||||||
|
using Persistence.Models;
|
||||||
|
|
||||||
namespace Persistence.Repository;
|
namespace Persistence.Repository;
|
||||||
public static class DependencyInjection
|
public static class DependencyInjection
|
||||||
@ -24,7 +25,8 @@ public static class DependencyInjection
|
|||||||
services.AddScoped<IPersistenceDbContext>(provider => provider.GetRequiredService<PersistenceDbContext>());
|
services.AddScoped<IPersistenceDbContext>(provider => provider.GetRequiredService<PersistenceDbContext>());
|
||||||
|
|
||||||
services.AddTransient<ITimeSeriesDataRepository<DataSaubDto>, TimeSeriesDataRepository<DataSaub, DataSaubDto>>();
|
services.AddTransient<ITimeSeriesDataRepository<DataSaubDto>, TimeSeriesDataRepository<DataSaub, DataSaubDto>>();
|
||||||
|
services.AddTransient<IChangeLogRepository<LogDto, ChangeLogDto<LogDto>>, ChangeLogRepository<ChangeLog, LogDto, ChangeLogDto<LogDto>>>();
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
71
Persistence.Repository/Repositories/ChangeLogRepository.cs
Normal file
71
Persistence.Repository/Repositories/ChangeLogRepository.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Persistence.Models;
|
||||||
|
using Persistence.Repositories;
|
||||||
|
|
||||||
|
namespace Persistence.Repository.Repositories
|
||||||
|
{
|
||||||
|
public abstract class ChangeLogRepository<TEntity, TDto, TChangeLogDto> : IChangeLogRepository<TDto, TChangeLogDto>
|
||||||
|
where TEntity : class
|
||||||
|
where TDto : class, IChangeLogAbstract, new()
|
||||||
|
where TChangeLogDto : ChangeLogDto<TDto>
|
||||||
|
{
|
||||||
|
private DbContext db;
|
||||||
|
|
||||||
|
public ChangeLogRepository(DbContext db)
|
||||||
|
{
|
||||||
|
this.db = db;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual IQueryable<TEntity> GetQueryReadOnly() => db.Set<TEntity>();
|
||||||
|
|
||||||
|
public Task<int> Clear(int idUser, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<int> ClearAndInsertRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IEnumerable<TChangeLogDto>> GetChangeLogForDate(DateTimeOffset? updateFrom, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IEnumerable<TDto>> GetCurrent(DateTimeOffset moment, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IEnumerable<DateOnly>> GetDatesChange(CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<IEnumerable<TDto>> GetGtDate(DateTimeOffset dateBegin, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<int> InsertRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<int> MarkAsDeleted(int idUser, IEnumerable<int> ids, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<int> UpdateOrInsertRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<int> UpdateRange(int idUser, IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -59,4 +59,9 @@ public interface IChangeLogAbstract
|
|||||||
/// Id заменяемой записи
|
/// Id заменяемой записи
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? IdPrevious { get; set; }
|
public int? IdPrevious { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Id последующей записи
|
||||||
|
/// </summary>
|
||||||
|
public int? IdNext { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Persistence.Repositories;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDto"></typeparam>
|
/// <typeparam name="TDto"></typeparam>
|
||||||
public interface IChangeLogRepository<TDto, TChangeLogDto> : ISyncRepository<TDto>
|
public interface IChangeLogRepository<TDto, TChangeLogDto> : ISyncRepository<TDto>
|
||||||
where TDto : class, ITimeSeriesAbstractDto, new()
|
where TDto : class, IChangeLogAbstract, new()
|
||||||
where TChangeLogDto : ChangeLogDto<TDto>
|
where TChangeLogDto : ChangeLogDto<TDto>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user