diff --git a/Persistence.API/Controllers/ChangeLogController.cs b/Persistence.API/Controllers/ChangeLogController.cs new file mode 100644 index 0000000..b982382 --- /dev/null +++ b/Persistence.API/Controllers/ChangeLogController.cs @@ -0,0 +1,61 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Persistence.Database.Model; +using Persistence.Models; +using Persistence.Repositories; + +namespace Persistence.API.Controllers; + +[ApiController] +[Authorize] +[Route("api/[controller]")] +public class ChangeLogRotorController : ControllerBase, IChangeLogApi> +{ + private IChangeLogRepository> repository; + + public ChangeLogRotorController(IChangeLogRepository> repository) + { + this.repository = repository; + } + public async Task> Add(ProcessMapRotorDto dto, CancellationToken token) + { + await repository.InsertRange(0, [dto], token); + + return null; + } + + public Task> AddRange(IEnumerable dtos, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task> Delete(int id, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task> DeleteRange(IEnumerable ids, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task>> GetChangeLogCurrent(CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task>>> GetChangeLogForDate(DateTimeOffset historyMoment, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task> Update(ProcessMapRotorDto dto, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task> UpdateRange(IEnumerable dtos, CancellationToken token) + { + throw new NotImplementedException(); + } +} diff --git a/Persistence.Database/Entity/ChangeLogAbstractData.cs b/Persistence.Database/Entity/ChangeLog.cs similarity index 81% rename from Persistence.Database/Entity/ChangeLogAbstractData.cs rename to Persistence.Database/Entity/ChangeLog.cs index ffc19c9..f25f61b 100644 --- a/Persistence.Database/Entity/ChangeLogAbstractData.cs +++ b/Persistence.Database/Entity/ChangeLog.cs @@ -5,9 +5,9 @@ using System.ComponentModel.DataAnnotations; namespace Persistence.Database.Model; /// -/// Часть записи описывающая изменение +/// Часть записи, описывающая изменение /// -public class ChangeLog : IChangeLogAbstractData +public class ChangeLog : IChangeLog { /// /// Ид записи @@ -15,6 +15,12 @@ public class ChangeLog : IChangeLogAbstractData [Key, Column("Id")] public Guid Id { get; set; } + /// + /// Дискриминатор таблицы + /// + [Column("IdDiscriminator")] + public Guid IdDiscriminator { get; set; } + /// /// Автор изменения /// diff --git a/Persistence.Database/Entity/ChangeLogWithWellDepthAndSectionId.cs b/Persistence.Database/Entity/ChangeLogWithWellDepthAndSectionId.cs new file mode 100644 index 0000000..abbe58f --- /dev/null +++ b/Persistence.Database/Entity/ChangeLogWithWellDepthAndSectionId.cs @@ -0,0 +1,29 @@ + +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; + +namespace Persistence.Database.Model; + +/// +/// Часть записи, описывающая изменение данных, содержащие начальную и конечную глубину, а также секцию +/// +public class ChangeLogWithWellDepthAndSectionId : ChangeLog +{ + /// + /// Глубина забоя на дату начала интервала + /// + [Column("DepthStart")] + public double? DepthStart { get; set; } + + /// + /// Глубина забоя на дату окончания интервала + /// + [Column("DepthEnd")] + public double? DepthEnd { get; set; } + + /// + /// Ключ секции + /// + [Column("IdSection")] + public Guid IdSection { get; set; } +} diff --git a/Persistence.Database/Entity/IChangeLogAbstractData.cs b/Persistence.Database/Entity/IChangeLog.cs similarity index 84% rename from Persistence.Database/Entity/IChangeLogAbstractData.cs rename to Persistence.Database/Entity/IChangeLog.cs index 750fef4..f8a5b15 100644 --- a/Persistence.Database/Entity/IChangeLogAbstractData.cs +++ b/Persistence.Database/Entity/IChangeLog.cs @@ -4,7 +4,7 @@ namespace Persistence.Database.Model; /// /// Часть записи описывающая изменение /// -public interface IChangeLogAbstractData +public interface IChangeLog { /// /// Ид записи @@ -14,12 +14,12 @@ public interface IChangeLogAbstractData /// /// Автор изменения /// - public int IdAuthor { get; set; } + public Guid IdAuthor { get; set; } /// /// Редактор /// - public int? IdEditor { get; set; } + public Guid? IdEditor { get; set; } /// /// Дата создания записи @@ -34,7 +34,7 @@ public interface IChangeLogAbstractData /// /// Id заменяющей записи /// - public int? IdNext { get; set; } + public Guid? IdNext { get; set; } /// /// Значение diff --git a/Persistence.Repository/Repositories/ChangeLogRepository.cs b/Persistence.Repository/Repositories/ChangeLogRepository.cs new file mode 100644 index 0000000..046e2bd --- /dev/null +++ b/Persistence.Repository/Repositories/ChangeLogRepository.cs @@ -0,0 +1,68 @@ +using Mapster; +using Microsoft.EntityFrameworkCore; +using Persistence.Database.Model; +using Persistence.Models; +using Persistence.Repositories; + +namespace Persistence.Repository.Repositories; +public class ChangeLogRepository : IChangeLogRepository + where TDto : class, IChangeLogDto, new() + where TChangeLogDto : ChangeLogDto +{ + private DbContext db; + + public ChangeLogRepository(DbContext db) + { + this.db = db; + } + + public Task Clear(int idUser, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task ClearAndInsertRange(int idUser, IEnumerable dtos, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task> GetChangeLogForDate(DateTimeOffset? updateFrom, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task> GetCurrent(DateTimeOffset moment, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task> GetDatesChange(CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task> GetGtDate(DateTimeOffset dateBegin, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task InsertRange(int idUser, IEnumerable dtos, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task MarkAsDeleted(int idUser, IEnumerable ids, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task UpdateOrInsertRange(int idUser, IEnumerable dtos, CancellationToken token) + { + throw new NotImplementedException(); + } + + public Task UpdateRange(int idUser, IEnumerable dtos, CancellationToken token) + { + throw new NotImplementedException(); + } +} diff --git a/Persistence/Models/ChangeLogDto.cs b/Persistence/Models/ChangeLogDto.cs index d9acc66..14e937b 100644 --- a/Persistence/Models/ChangeLogDto.cs +++ b/Persistence/Models/ChangeLogDto.cs @@ -4,7 +4,7 @@ namespace Persistence.Models; /// /// Часть записи описывающая изменение /// -public class ChangeLogDto : IChangeLogAbstractDto +public class ChangeLogDto : IChangeLogDto where T: class { /// diff --git a/Persistence/Models/IChangeLogAbstractDto.cs b/Persistence/Models/IChangeLogAbstractDto.cs deleted file mode 100644 index b9fd209..0000000 --- a/Persistence/Models/IChangeLogAbstractDto.cs +++ /dev/null @@ -1,42 +0,0 @@ -namespace Persistence.Models; - -/// -/// Часть записи описывающая изменение -/// -public interface IChangeLogAbstractDto -{ - /// - /// Ид записи - /// - public int Id { get; set; } - - /// - /// Автор изменения - /// - public int IdAuthor { get; set; } - - /// - /// Редактор - /// - public int? IdEditor { get; set; } - - /// - /// Дата создания записи - /// - public DateTimeOffset Creation { get; set; } - - /// - /// Дата устаревания (например при удалении) - /// - public DateTimeOffset? Obsolete { get; set; } - - /// - /// Id заменяющей записи - /// - public int? IdNext { get; set; } - - /// - /// Значение - /// - public object Value { get; set; } -} diff --git a/Persistence/Models/IChangeLogDto.cs b/Persistence/Models/IChangeLogDto.cs new file mode 100644 index 0000000..09cfd09 --- /dev/null +++ b/Persistence/Models/IChangeLogDto.cs @@ -0,0 +1,42 @@ +namespace Persistence.Models; + +/// +/// Часть записи описывающая изменение +/// +public interface IChangeLogDto +{ + ///// + ///// Ид записи + ///// + //public int Id { get; set; } + + ///// + ///// Автор изменения + ///// + //public int IdAuthor { get; set; } + + ///// + ///// Редактор + ///// + //public int? IdEditor { get; set; } + + ///// + ///// Дата создания записи + ///// + //public DateTimeOffset Creation { get; set; } + + ///// + ///// Дата устаревания (например при удалении) + ///// + //public DateTimeOffset? Obsolete { get; set; } + + ///// + ///// Id заменяющей записи + ///// + //public int? IdNext { get; set; } + + ///// + ///// Значение + ///// + //public object Value { get; set; } +} diff --git a/Persistence/Models/ProcessMapRotorDto.cs b/Persistence/Models/ProcessMapRotorDto.cs new file mode 100644 index 0000000..316f07a --- /dev/null +++ b/Persistence/Models/ProcessMapRotorDto.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Persistence.Models; +public class ProcessMapRotorDto : IChangeLogDto +{ + public string Caption { get; set; } +} diff --git a/Persistence/Repositories/IChangeLogRepository.cs b/Persistence/Repositories/IChangeLogRepository.cs index c12c61b..3435ee1 100644 --- a/Persistence/Repositories/IChangeLogRepository.cs +++ b/Persistence/Repositories/IChangeLogRepository.cs @@ -7,7 +7,7 @@ namespace Persistence.Repositories; /// /// public interface IChangeLogRepository : ISyncRepository - where TDto : class, ITimeSeriesAbstractDto, new() + where TDto : class, IChangeLogDto, new() where TChangeLogDto : ChangeLogDto { ///