using Domain.Entities.Store; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Store; public sealed class GameConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(Game), t => t.HasComment("상점 제휴 게임")); builder.HasKey(x => x.ID); builder.Property(x => x.Code).HasMaxLength(6).HasComment("게임 코드 (UNIQUE, 외부 연동/내부 식별)"); builder.Property(x => x.KorName).HasMaxLength(255).IsRequired().HasComment("게임 한글명"); builder.Property(x => x.EngName).HasMaxLength(255).HasComment("게임 영문명"); builder.Property(x => x.Publisher).HasMaxLength(100).IsRequired().HasComment("게임사/퍼블리셔"); builder.Property(x => x.Thumbnail).HasMaxLength(500).HasComment("작은 이미지 (목록 카드용)"); builder.Property(x => x.BigImage).HasMaxLength(500).HasComment("큰 이미지 (상세/배너용)"); builder.Property(x => x.Description).HasColumnType("nvarchar(max)").HasComment("게임 소개 (CKEditor HTML)"); builder.Property(x => x.CommissionRate).HasPrecision(10, 7).IsRequired().HasComment("게임사 수익률(%) — 0~100, 소수점 7자리"); builder.Property(x => x.Link).HasMaxLength(255).HasComment("게임 다운로드/공식 사이트 주소"); builder.Property(x => x.TrailerUrl).HasMaxLength(500).HasComment("YouTube 예고편 URL"); builder.Property(x => x.MinSpec).HasColumnType("nvarchar(max)").HasComment("최소 사양 (자유 텍스트)"); builder.Property(x => x.RecommendedSpec).HasColumnType("nvarchar(max)").HasComment("권장 사양 (자유 텍스트)"); builder.Property(x => x.ReleaseDate).HasComment("게임 출시일"); builder.Property(x => x.IsActive).IsRequired(); builder.Property(x => x.Order).IsRequired(); builder.Property(x => x.CreatedAt).IsRequired(); builder.Property(x => x.UpdatedAt); builder.HasIndex(x => x.KorName).IsUnique(); // Code 는 NULL 허용하면서 NOT NULL 값에 대해서만 UNIQUE (SQL Server filtered index) builder.HasIndex(x => x.Code).IsUnique().HasFilter("[Code] IS NOT NULL"); builder.HasIndex(x => new { x.IsActive, x.Order }); } }