using Domain.Entities.Stocks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Stocks; public sealed class CommodityDailyTradeConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(CommodityDailyTrade), t => t.HasComment("일반상품(석유/금/배출권) 일별매매 시세 (KRX OpenAPI gen)")); builder.HasKey(x => x.ID); builder.HasIndex(x => new { x.CommodityMarket, x.Code, x.TradeDate }).IsUnique(); builder.HasIndex(x => new { x.CommodityMarket, x.TradeDate, x.TradeValue }).IsDescending(false, false, true); builder.Property(x => x.CommodityMarket).HasConversion().IsRequired().HasComment("일반상품 시장 구분 (1=석유, 2=금, 3=배출권)"); builder.Property(x => x.Code).HasMaxLength(40).IsRequired().HasComment("단축코드 (ISU_CD) — 석유는 OIL_NM(유종구분)"); builder.Property(x => x.Name).HasMaxLength(100).IsRequired().HasComment("종목명 (ISU_NM) — 석유는 유종구분"); builder.Property(x => x.Close).HasPrecision(18, 2).HasComment("종가 (TDD_CLSPRC) — 석유는 가중평균가격_경쟁"); builder.Property(x => x.Open).HasPrecision(18, 2).HasComment("시가 (TDD_OPNPRC) — 석유 0"); builder.Property(x => x.High).HasPrecision(18, 2).HasComment("고가 (TDD_HGPRC) — 석유 0"); builder.Property(x => x.Low).HasPrecision(18, 2).HasComment("저가 (TDD_LWPRC) — 석유 0"); builder.Property(x => x.ChangeAmount).HasPrecision(18, 2).HasComment("전일 대비 (CMPPREVDD_PRC) — 금/배출권만"); builder.Property(x => x.ChangeRate).HasPrecision(9, 2).HasComment("등락률 % (FLUC_RT) — 금/배출권만"); builder.Property(x => x.WeightedDiscussionPrice).HasPrecision(18, 2).HasComment("가중평균가격_협의 (WT_DIS_AVG_PRC) — 석유만"); builder.Property(x => x.Volume).HasComment("거래량 (ACC_TRDVOL)"); builder.Property(x => x.TradeValue).HasComment("거래대금 (ACC_TRDVAL, 원)"); } }