using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using SPMS.Domain.Entities; namespace SPMS.Infrastructure.Persistence.Configurations; public class SystemLogConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("SystemLog"); builder.HasKey(e => e.Id); builder.Property(e => e.Id).ValueGeneratedOnAdd(); builder.Property(e => e.ServiceId); builder.Property(e => e.AdminId); builder.Property(e => e.Action).HasMaxLength(100).IsRequired(); builder.Property(e => e.TargetType).HasMaxLength(50); builder.Property(e => e.TargetId); builder.Property(e => e.Details).HasColumnType("json"); builder.Property(e => e.IpAddress).HasMaxLength(45); builder.Property(e => e.CreatedAt).IsRequired(); builder.HasOne(e => e.Service) .WithMany() .HasForeignKey(e => e.ServiceId) .OnDelete(DeleteBehavior.Restrict); builder.HasOne(e => e.Admin) .WithMany() .HasForeignKey(e => e.AdminId) .OnDelete(DeleteBehavior.Restrict); builder.HasIndex(e => e.CreatedAt); } }