feat: add content navigation and tenant configuration

This commit is contained in:
xiong
2026-07-26 05:05:24 +08:00
parent 5dfb68d8cc
commit e41b38e3a1
13 changed files with 6197 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Tiku.Domain.Catalog;
using Tiku.Domain.Content;
using Tiku.Domain.Identity;
using Tiku.Domain.QuestionBanks;
@@ -37,6 +38,7 @@ internal sealed class QuestionConfiguration : IEntityTypeConfiguration<Question>
builder.Property(entity => entity.Type).HasMaxLength(50);
builder.Property(entity => entity.TypeLabel).HasMaxLength(100);
builder.Property(entity => entity.Tags).IsJson("[]");
builder.Property(entity => entity.ExamMarkers).IsJson("{}");
builder.Property(entity => entity.MediaUrl).HasMaxLength(2048);
builder.Property(entity => entity.Status).HasSnakeCaseEnum();
builder.HasIndex(entity => new { entity.TenantId, entity.LegacyId }).IsUnique();
@@ -57,6 +59,18 @@ internal sealed class QuestionConfiguration : IEntityTypeConfiguration<Question>
.HasForeignKey(entity => new { entity.TenantId, entity.NodeId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne<ContentEntry>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.EntryId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne<ContentNode>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.ContentNodeId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne<QuestionCollection>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.PrimaryCollectionId })
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne<QuestionVersion>().WithMany()
.HasForeignKey(entity => new { entity.TenantId, entity.Id, entity.CurrentVersionId })