using Microsoft.EntityFrameworkCore; using NetCorePal.Extensions.Domain; using Fengling.RiskControl.Domain.Aggregates.RiskRules; using Fengling.RiskControl.Domain.Aggregates.RiskScores; using Fengling.RiskControl.Domain.Aggregates.RiskAlerts; using Fengling.RiskControl.Domain.Aggregates.LotteryActivities; namespace Fengling.RiskControl.Infrastructure; public class RiskControlDbContext : DbContext { public DbSet RiskRules => Set(); public DbSet RiskScores => Set(); public DbSet RiskAlerts => Set(); public DbSet LotteryActivities => Set(); private RiskControlDbContext() { } public RiskControlDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(builder => { builder.ToTable("rc_risk_rules"); builder.HasKey(r => r.Id); builder.Property(r => r.Name).HasMaxLength(100).IsRequired(); builder.Property(r => r.Description).HasMaxLength(500); builder.Property(r => r.ConfigJson).HasColumnName("config_json"); builder.Property(r => r.IsActive).HasDefaultValue(true); }); modelBuilder.Entity(builder => { builder.ToTable("rc_risk_scores"); builder.HasKey(s => s.Id); builder.Property(s => s.MemberId).IsRequired(); builder.Property(s => s.EntityType).HasMaxLength(50).IsRequired(); builder.Property(s => s.EntityId).HasMaxLength(100).IsRequired(); }); modelBuilder.Entity(builder => { builder.ToTable("rc_risk_alerts"); builder.HasKey(a => a.Id); builder.Property(a => a.MemberId).IsRequired(); builder.Property(a => a.AlertType).HasMaxLength(50).IsRequired(); builder.Property(a => a.Description).HasMaxLength(500); }); modelBuilder.Entity(builder => { builder.ToTable("rc_lottery_activities"); builder.HasKey(l => l.Id); builder.Property(l => l.MemberId).IsRequired(); builder.Property(l => l.ActivityType).HasMaxLength(50).IsRequired(); builder.Property(l => l.IpAddress).HasMaxLength(50); builder.Property(l => l.DeviceId).HasMaxLength(100); }); } }