using Domain.Entities.Stocks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Stocks; public sealed class IndexDailyPriceConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(IndexDailyPrice), t => t.HasComment("지수(시장) 일별 마감 시세 (KRX OpenAPI)")); builder.HasKey(x => x.ID); builder.HasIndex(x => new { x.Series, x.IndexName, x.TradeDate }).IsUnique(); builder.HasIndex(x => x.TradeDate); builder.Property(x => x.Series).HasConversion().IsRequired().HasComment("계열 구분 (1=KOSPI, 2=KOSDAQ, 3=KRX)"); builder.Property(x => x.IndexName).HasMaxLength(100).IsRequired().HasComment("지수명"); builder.Property(x => x.Close).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.Value).HasComment("거래대금 (원)"); builder.Property(x => x.MarketCap).HasComment("상장시가총액 (원)"); } }