Complete MVP implementation (Étape 1) covering: - Domain: primitives (Entity<TId>, ValueObject), 10 entities, 6 enums - EF Core: AppDbContext + Identity, 8 EntityTypeConfigurations, audit/soft-delete interceptors, initial migration - Application: service interfaces, DTOs, FluentValidation, ServiceResult pattern - Security: Identity + JWT + API Key multi-auth, role-based permissions, constant-time key validation - API: Auth/Sites/Agents controllers with explicit auth scheme policies - Workers: Hangfire PostgreSQL setup with schema isolation, HeartbeatMonitorJob - Agent: registration service + 30s heartbeat loop - Docker: multi-stage Dockerfiles for central + agent, docker-compose.yml - CI/CD: GitHub Actions pipeline with build+test and Docker build - Tests: 13 domain tests (Site, Agent, Camera entities) Architecture decisions per deliberation council: - API Key via AuthenticationHandler<T> (not middleware) - Explicit [Authorize(AuthenticationSchemes)] on all endpoints - Event/Recording/Person/Vehicle deferred from initial migration - Hangfire compatible with .NET 10 (v1.8.17)
29 lines
868 B
C#
29 lines
868 B
C#
namespace Heimdall.Domain.Primitives;
|
|
|
|
/// <summary>
|
|
/// Base class for all domain entities with a strongly-typed identifier.
|
|
/// </summary>
|
|
public abstract class Entity<TId> : IEquatable<Entity<TId>>
|
|
where TId : notnull
|
|
{
|
|
public TId Id { get; protected set; } = default!;
|
|
|
|
protected Entity(TId id) => Id = id;
|
|
|
|
protected Entity() { } // EF Core
|
|
|
|
public override bool Equals(object? obj) =>
|
|
obj is Entity<TId> other && Id.Equals(other.Id);
|
|
|
|
public bool Equals(Entity<TId>? other) =>
|
|
other is not null && Id.Equals(other.Id);
|
|
|
|
public override int GetHashCode() => Id.GetHashCode();
|
|
|
|
public static bool operator ==(Entity<TId>? left, Entity<TId>? right) =>
|
|
left is null ? right is null : left.Equals(right);
|
|
|
|
public static bool operator !=(Entity<TId>? left, Entity<TId>? right) =>
|
|
!(left == right);
|
|
}
|