feat(persons): add person manager with known face registry and CRUD API
This commit is contained in:
1 parent
c5728fa810
commit
129a6148f5
15 files changed
+2404
-63
No files matched your search
@@ -0,0 +1,35 @@
|
||||
using Heimdall.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Heimdall.Infrastructure.Data.Configurations;
|
||||
|
||||
public class KnownFaceConfiguration : IEntityTypeConfiguration<KnownFace>
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new();
|
||||
|
||||
public void Configure(EntityTypeBuilder<KnownFace> builder)
|
||||
{
|
||||
builder.ToTable("known_faces");
|
||||
|
||||
builder.HasKey(f => f.Id);
|
||||
|
||||
builder.Property(f => f.ThumbnailUrl)
|
||||
.HasMaxLength(2000)
|
||||
.IsUnicode(false);
|
||||
|
||||
builder.Property(f => f.SourceEventId)
|
||||
.HasMaxLength(100)
|
||||
.IsUnicode(false);
|
||||
|
||||
// Store float[] as JSONB
|
||||
builder.Property(f => f.Embedding)
|
||||
.HasColumnType("jsonb")
|
||||
.HasConversion(
|
||||
v => JsonSerializer.Serialize(v, JsonOptions),
|
||||
v => JsonSerializer.Deserialize<float[]>(v, JsonOptions) ?? Array.Empty<float>());
|
||||
|
||||
builder.HasIndex(f => f.PersonId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Heimdall.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Heimdall.Infrastructure.Data.Configurations;
|
||||
|
||||
public class PersonConfiguration : IEntityTypeConfiguration<Person>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Person> builder)
|
||||
{
|
||||
builder.ToTable("persons");
|
||||
|
||||
builder.HasKey(p => p.Id);
|
||||
|
||||
builder.Property(p => p.DisplayName)
|
||||
.HasMaxLength(200)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(p => p.Notes)
|
||||
.HasMaxLength(2000);
|
||||
|
||||
builder.Property(p => p.PhotoUrl)
|
||||
.HasMaxLength(2000)
|
||||
.IsUnicode(false);
|
||||
|
||||
builder.Property(p => p.Category)
|
||||
.HasMaxLength(50)
|
||||
.IsUnicode(false);
|
||||
|
||||
builder.HasIndex(p => p.DisplayName);
|
||||
builder.HasIndex(p => p.Category);
|
||||
builder.HasIndex(p => p.IsWatchlisted);
|
||||
|
||||
// OwnsMany for KnownFace (stored as JSONB or separate table)
|
||||
builder.HasMany(p => p.Faces)
|
||||
.WithOne(f => f.Person)
|
||||
.HasForeignKey(f => f.PersonId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user