admin page phaze2

This commit is contained in:
2026-09-25 16:34:36 +03:30
parent 9d4ad26dcc
commit 6abb5aae15
19 changed files with 2847 additions and 6 deletions

View File

@@ -31,6 +31,7 @@ public sealed class GreenHomeDbContext : DbContext
public DbSet<Domain.DevicePostImage> DevicePostImages => Set<Domain.DevicePostImage>();
public DbSet<Domain.PowerOutageLog> PowerOutageLogs => Set<Domain.PowerOutageLog>();
public DbSet<Domain.UsageCounter> UsageCounters => Set<Domain.UsageCounter>();
public DbSet<Domain.AdminAuditLog> AdminAuditLogs => Set<Domain.AdminAuditLog>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@@ -458,5 +459,20 @@ public sealed class GreenHomeDbContext : DbContext
b.HasIndex(x => new { x.UserId, x.Date }).IsUnique();
b.HasIndex(x => x.Date);
});
modelBuilder.Entity<Domain.AdminAuditLog>(b =>
{
b.ToTable("AdminAuditLogs");
b.HasKey(x => x.Id);
b.Property(x => x.Action).IsRequired().HasMaxLength(100);
b.Property(x => x.TargetId).IsRequired().HasMaxLength(100);
b.Property(x => x.Details).HasMaxLength(2000);
b.HasOne(x => x.AdminUser)
.WithMany()
.HasForeignKey(x => x.AdminUserId)
.OnDelete(DeleteBehavior.Restrict);
b.HasIndex(x => x.At);
b.HasIndex(x => x.AdminUserId);
});
}
}