Files
Heimdall/src/Heimdall.Infrastructure/Data/Configurations/CameraDiscoveryResultConfiguration.cs
T

106 lines
3.8 KiB
C#
Raw Normal View History

using Heimdall.Domain.Entities;
using Heimdall.Domain.Enums;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Heimdall.Infrastructure.Data.Configurations;
public class CameraDiscoveryResultConfiguration : IEntityTypeConfiguration<CameraDiscoveryResult>
{
public void Configure(EntityTypeBuilder<CameraDiscoveryResult> builder)
{
builder.ToTable("camera_discovery_results");
builder.HasKey(r => r.Id);
// ── Identification ──────────────────────────────────────────
builder.Property(r => r.IpAddress)
.HasMaxLength(45)
.IsRequired()
.IsUnicode(false);
builder.Property(r => r.MacAddress)
.HasMaxLength(17)
.IsUnicode(false);
builder.Property(r => r.Vendor)
.HasMaxLength(100)
.IsUnicode(false);
builder.Property(r => r.Hostname)
.HasMaxLength(255)
.IsUnicode(false);
// ── Classification ──────────────────────────────────────────
builder.Property(r => r.DetectedType)
.HasConversion<string>()
.HasMaxLength(20)
.IsUnicode(false);
builder.Property(r => r.DiscoveryMethod)
.HasConversion<string>()
.HasMaxLength(20)
.IsUnicode(false);
// ── Ports ───────────────────────────────────────────────────
builder.Property(r => r.OpenPorts)
.HasColumnType("integer[]")
.IsUnicode(false);
// ONVIF
builder.Property(r => r.OnvifDeviceServiceUrl)
.HasMaxLength(500)
.IsUnicode(false);
builder.Property(r => r.OnvifName)
.HasMaxLength(200)
.IsUnicode(false);
builder.Property(r => r.OnvifHardware)
.HasMaxLength(200)
.IsUnicode(false);
builder.Property(r => r.OnvifPort);
// HTTP
builder.Property(r => r.HttpServerHeader)
.HasMaxLength(200)
.IsUnicode(false);
builder.Property(r => r.HttpStatusCode);
builder.Property(r => r.HttpPort);
// HomeKit
builder.Property(r => r.HomeKitName)
.HasMaxLength(200)
.IsUnicode(false);
builder.Property(r => r.HomeKitDeviceId)
.HasMaxLength(50)
.IsUnicode(false);
builder.Property(r => r.HomeKitModel)
.HasMaxLength(200)
.IsUnicode(false);
// ── Status ──────────────────────────────────────────────────
builder.Property(r => r.ProbedAt)
.HasDefaultValueSql("NOW()");
// ── Indexes ─────────────────────────────────────────────────
builder.HasIndex(r => r.SiteId);
builder.HasIndex(r => r.IpAddress);
builder.HasIndex(r => r.IsProcessed);
// ── Relationships ───────────────────────────────────────────
builder.HasOne(r => r.Site)
.WithMany()
.HasForeignKey(r => r.SiteId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasMany(r => r.DiscoveredStreams)
.WithOne(ds => ds.DiscoveryResult)
.HasForeignKey(ds => ds.DiscoveryResultId)
.OnDelete(DeleteBehavior.Cascade);
}
}