forked from gongxuegit/tiku-backend.net
feat: enforce tenant isolation and shared question bank
This commit is contained in:
@@ -23,6 +23,9 @@ internal sealed class TenantConfiguration : IEntityTypeConfiguration<Tenant>
|
||||
|
||||
builder.HasIndex(entity => entity.Slug).IsUnique();
|
||||
builder.HasIndex(entity => entity.LegacyId).IsUnique();
|
||||
builder.HasIndex(entity => entity.Mode)
|
||||
.IsUnique()
|
||||
.HasFilter("mode = 'platform_owned'");
|
||||
|
||||
builder.HasOne<User>()
|
||||
.WithMany()
|
||||
@@ -67,7 +70,10 @@ internal sealed class TenantDomainConfiguration : IEntityTypeConfiguration<Tenan
|
||||
builder.Property(entity => entity.DomainType).HasSnakeCaseEnum();
|
||||
builder.Property(entity => entity.Status).HasSnakeCaseEnum();
|
||||
builder.Property(entity => entity.VerificationToken).HasMaxLength(256);
|
||||
builder.HasIndex(entity => entity.Host).IsUnique();
|
||||
builder.Property(entity => entity.LastFailureReason).HasMaxLength(2000);
|
||||
builder.HasIndex(entity => entity.Host)
|
||||
.IsUnique()
|
||||
.HasAnnotation("Tiku:GlobalUnique", true);
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.IsPrimary })
|
||||
.IsUnique()
|
||||
.HasFilter("is_primary");
|
||||
@@ -114,3 +120,29 @@ internal sealed class TenantSettingsConfiguration : IEntityTypeConfiguration<Ten
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class TenantFrontendConfigConfiguration : IEntityTypeConfiguration<TenantFrontendConfig>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<TenantFrontendConfig> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("tenant_frontend_configs");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.HasIndex(entity => entity.TenantId).IsUnique();
|
||||
builder.Property(entity => entity.ConfigVersion).IsConcurrencyToken();
|
||||
builder.Property(entity => entity.PublishedBranding).IsJson("{}");
|
||||
builder.Property(entity => entity.PublishedTheme).IsJson("{}");
|
||||
builder.Property(entity => entity.PublishedFeatures).IsJson("{}");
|
||||
builder.Property(entity => entity.PublishedNavigation).IsJson("[]");
|
||||
builder.Property(entity => entity.PublishedHomeModules).IsJson("[]");
|
||||
builder.Property(entity => entity.DraftBranding).IsJson("{}");
|
||||
builder.Property(entity => entity.DraftTheme).IsJson("{}");
|
||||
builder.Property(entity => entity.DraftFeatures).IsJson("{}");
|
||||
builder.Property(entity => entity.DraftNavigation).IsJson("[]");
|
||||
builder.Property(entity => entity.DraftHomeModules).IsJson("[]");
|
||||
builder.ToTable(table =>
|
||||
{
|
||||
table.HasCheckConstraint("ck_tenant_frontend_configs_schema_version", "schema_version > 0");
|
||||
table.HasCheckConstraint("ck_tenant_frontend_configs_config_version", "config_version > 0");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user