feat: создана структура проекта, core, domain, infrastructure. Перенесены enum и task согласно архитектуры

This commit is contained in:
Mikhail Trubnikov
2026-04-13 16:58:30 +10:00
parent 0bbbac09fe
commit da83aff19c
160 changed files with 482 additions and 267 deletions

View File

@@ -0,0 +1,18 @@
namespace PARR.Domain.Entities.Base.History.Base
{
/// <summary>
/// Таблица отслеживания изменений основной таблицы (таблица истории)
/// </summary>
public interface IHistoryTable : IBaseEntity
{
/// <summary>
/// Id записи в родительской таблице
/// </summary>
public Guid ParentId { get; set; }
/// <summary>
/// Дата добавления в историю
/// </summary>
public DateTimeOffset DateAddedToHistory { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace PARR.Domain.Entities.Base.History.Base
{
/// <summary>
/// По этому интерфейсу определям, что хотим вести историю.
/// В родительской таблице, по которой ведется история, указываются настройки истории.
/// </summary>
/// <typeparam name="HistoryTable">Таблица истории</typeparam>
public interface IMyHistory<HistoryTable> where HistoryTable : class { }
}

View File

@@ -0,0 +1,14 @@
using PARR.Domain.Enums;
namespace PARR.Domain.Entities.Base.History
{
/// <summary>
/// Инициатор изменений, ведение истории
/// </summary>
public class HistoryInitiator : IHistoryInitiator
{
public string? InitiatorIp { get; set; }
public ParrComponentsEnum? InitiatorParrComponentId { get; set; }
public string? InitiatorComment { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using PARR.Domain.Enums;
namespace PARR.Domain.Entities.Base.History
{
/// <summary>
/// Инициатор изменений, ведение истории
/// </summary>
public interface IHistoryInitiator
{
/// <summary>
/// IP инициатора изменений (пользователь)
/// </summary>
public string? InitiatorIp { get; set; }
/// <summary>
/// Id инициатора компонента ПАРР
/// </summary>
public ParrComponentsEnum? InitiatorParrComponentId { get; set; }
/// <summary>
/// Комментарий от инициатора
/// </summary>
public string? InitiatorComment { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
namespace PARR.Domain.Entities.Base.History
{
public interface ITemplateGeneralProps
{
public string Name { get; set; }
public bool IsActiveTemplate { get; set; }
public bool IsActiveSchedule { get; set; }
public DateTimeOffset? LastRun { get; set; }
public DateTimeOffset NextRun { get; set; }
}
}

View File

@@ -0,0 +1,12 @@

namespace PARR.Domain.Entities.Base
{
public interface IBaseEntity : IBaseEntityDateCreated, IBaseEntityDateModified
{
public Guid Id { get; set; }
//DateTimeOffset DateCreated { get; set; }
//DateTimeOffset? DateModified { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace PARR.Domain.Entities.Base
{
public interface IBaseEntityDateCreated
{
public DateTimeOffset DateCreated { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace PARR.Domain.Entities.Base
{
public interface IBaseEntityDateModified
{
public DateTimeOffset? DateModified { get; set; }
}
}

View File

@@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.TaskEntities
{
[Table("Errors", Schema = DatabaseSchemas.Task)]
[Comment("Таблица ошибок заданий")]
public class TaskError : IBaseEntity
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
[NotMapped]
public DateTimeOffset? DateModified { get; set; }
public Guid TaskId { get; set; }
public int AttemptNumber { get; set; }
public required string ErrorMessage { get; set; }
public string? StackTrace { get; set; }
[ForeignKey(nameof(TaskId))]
public TaskItem? TaskItem { get; set; }
}
}

View File

@@ -0,0 +1,52 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Entities.Base;
using PARR.Domain.Entities.Base.History;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.TaskEntities
{
[Table("Tasks", Schema = DatabaseSchemas.Task)]
[Comment("Таблица заданий")]
public class TaskItem : IBaseEntity, IHistoryInitiator
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public TaskTypeEnum TypeCode { get; set; }
public TaskItemStatusEnum StatusCode { get; set; }
public string? Payload { get; set; }
/// <summary>
/// Кол-во попыток
/// </summary>
public int RetryCount { get; set; }
/// <summary>
/// Дата завершения (устанавливается или когда Успех или когда Ошибка)
/// </summary>
public DateTimeOffset? ProcessedAt { get; set; }
public string? InitiatorIp { get; set; }
public ParrComponentsEnum? InitiatorParrComponentId { get; set; }
public string? InitiatorComment { get; set; }
[ForeignKey(nameof(TypeCode))]
public TaskType? TaskType { get; set; }
[ForeignKey(nameof(StatusCode))]
public TaskStatus? TaskStatus { get; set; }
public ICollection<TaskError> TaskErrors { get; set; } = new HashSet<TaskError>();
}
}

View File

@@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.TaskEntities
{
[Table("Statuses", Schema = DatabaseSchemas.Task)]
[Comment("Таблица статусов заданий")]
public class TaskStatus
{
[Key]
public TaskItemStatusEnum Code { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
public ICollection<TaskItem> Tasks { get; set; } = new HashSet<TaskItem>();
}
}

View File

@@ -0,0 +1,43 @@
using Microsoft.EntityFrameworkCore;
using PARR.Domain.Constants;
using PARR.Domain.Enums;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.Domain.Entities.TaskEntities
{
[Table("Types", Schema = DatabaseSchemas.Task)]
[Comment("Таблица типов заданий")]
public class TaskType
{
[Key]
public TaskTypeEnum Code { get; set; }
public required string Name { get; set; }
public required string Description { get; set; }
/// <summary>
/// Максимальное кол-во попыток
/// </summary>
public int MaxRetries { get; set; }
/// <summary>
/// Максимальное время выполнения
/// </summary>
public int MaxExecutionTimeMinutes { get; set; }
/// <summary>
/// Одновременно может быть только одна задача или несколько
/// </summary>
public bool IsSingleton { get; set; }
/// <summary>
/// Сколько дней хранить в БД
/// </summary>
public int RetentionDays { get; set; }
public ICollection<TaskItem> Tasks { get; set; } = new HashSet<TaskItem>();
}
}