forked from gongxuegit/tiku-backend.net
feat: add student video and profile experience
This commit is contained in:
@@ -310,3 +310,41 @@ internal sealed class QuestionVideoConfiguration : IEntityTypeConfiguration<Ques
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class VideoPlaybackProgressConfiguration : IEntityTypeConfiguration<VideoPlaybackProgress>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<VideoPlaybackProgress> builder)
|
||||
{
|
||||
builder.ConfigureTenantEntity("video_playback_progress");
|
||||
builder.ConfigureTimestamps();
|
||||
builder.Property(entity => entity.Metadata).IsJson("{}");
|
||||
builder.Property(entity => entity.LastPlayedAt).HasDefaultValueSql("now()");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.UserId, entity.VideoId })
|
||||
.IsUnique()
|
||||
.HasFilter("question_id is null");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.UserId, entity.VideoId, entity.QuestionId })
|
||||
.IsUnique()
|
||||
.HasFilter("question_id is not null");
|
||||
builder.HasIndex(entity => new { entity.TenantId, entity.UserId, entity.LastPlayedAt });
|
||||
|
||||
builder.HasOne<User>().WithMany()
|
||||
.HasForeignKey(entity => entity.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
builder.HasOne<VideoExplanation>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.VideoId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
builder.HasOne<Question>().WithMany()
|
||||
.HasForeignKey(entity => new { entity.TenantId, entity.QuestionId })
|
||||
.HasPrincipalKey(entity => new { entity.TenantId, entity.Id })
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder.ToTable(table =>
|
||||
{
|
||||
table.HasCheckConstraint("ck_video_playback_progress_position", "position_seconds >= 0");
|
||||
table.HasCheckConstraint("ck_video_playback_progress_duration", "duration_seconds is null or duration_seconds >= 0");
|
||||
table.HasCheckConstraint("ck_video_playback_progress_watched", "watched_seconds >= 0");
|
||||
table.HasCheckConstraint("ck_video_playback_progress_play_count", "play_count >= 0");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user