feat: add learning reports and practice access persistence

This commit is contained in:
xiong
2026-07-26 05:24:55 +08:00
parent c217db4597
commit b2282cde8c
11 changed files with 9606 additions and 2 deletions

View File

@@ -19,9 +19,20 @@ internal sealed class PracticeSessionConfiguration : IEntityTypeConfiguration<Pr
builder.Property(entity => entity.StartedAt).HasDefaultValueSql("now()");
builder.Property(entity => entity.QuestionIds).IsJson("[]");
builder.Property(entity => entity.TotalScore).HasPrecision(8, 2);
builder.Property(entity => entity.AccessMode)
.HasSnakeCaseEnum()
.HasDefaultValue(PracticeAccessMode.Free);
builder.Property(entity => entity.AccessSnapshot).IsJson("{}");
builder.Property(entity => entity.Metadata).IsJson("{}");
builder.HasIndex(entity => new { entity.TenantId, entity.UserId, entity.StartedAt });
builder.ToTable(table =>
{
table.HasCheckConstraint(
"ck_practice_sessions_consumed_free_quota",
"consumed_free_quota >= 0");
});
builder.HasOne<User>().WithMany()
.HasForeignKey(entity => entity.UserId)
.OnDelete(DeleteBehavior.Cascade);