using Domain.Entities.Stocks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Stocks; public sealed class MarketQuoteSnapshotConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(MarketQuoteSnapshot), t => t.HasComment("주요 종목·상품 시세 최신 스냅샷 (Stooq 일1회 upsert, 카테고리/그룹별)")); builder.HasKey(x => x.ID); builder.HasIndex(x => x.Symbol).IsUnique(); builder.HasIndex(x => new { x.Category, x.GroupCode }); builder.Property(x => x.Symbol).HasMaxLength(30).IsRequired().HasComment("외부 소스(Stooq) 심볼"); builder.Property(x => x.Name).HasMaxLength(100).IsRequired().HasComment("표시명"); builder.Property(x => x.Category).HasConversion().HasComment("0 Stock,1 Commodity,2 Futures,3 Fx,4 BondYield"); builder.Property(x => x.GroupCode).HasMaxLength(40).IsRequired().HasComment("프론트 그룹 키"); builder.Property(x => x.CountryCode).HasMaxLength(2).IsRequired().HasComment("국가 코드 (ISO2, 상품은 빈값)"); builder.Property(x => x.Close).HasPrecision(18, 2).HasComment("종가"); builder.Property(x => x.PrevClose).HasPrecision(18, 2).HasComment("직전 거래일 종가"); builder.Property(x => x.ChangeVal).HasPrecision(18, 2).HasComment("전일 대비"); builder.Property(x => x.FlucRateBp).HasComment("등락률 basis point (%×100)"); builder.Property(x => x.Open).HasPrecision(18, 2).HasComment("시가"); builder.Property(x => x.High).HasPrecision(18, 2).HasComment("고가"); builder.Property(x => x.Low).HasPrecision(18, 2).HasComment("저가"); builder.Property(x => x.Volume).HasComment("거래량"); } }