using Domain.Entities.Stocks; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Stocks; public sealed class StockConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasIndex(x => x.Code).IsUnique(); builder.HasIndex(x => x.ISIN).IsUnique().HasFilter("[ISIN] IS NOT NULL"); builder.HasIndex(x => new { x.Market, x.IsActive }); builder.HasIndex(x => x.Name); builder.HasIndex(x => x.CorpCode); builder.HasIndex(x => x.IssucoCustno); builder.ToTable(nameof(Stock), t => t.HasComment("종목 마스터 (KRX 상장종목)")); builder.HasKey(x => x.ID); builder.Property(x => x.Code).HasMaxLength(6).IsFixedLength().IsRequired().HasComment("단축코드"); builder.Property(x => x.ISIN).HasMaxLength(12).IsFixedLength().HasComment("표준코드"); builder.Property(x => x.Name).HasMaxLength(100).IsRequired(); builder.Property(x => x.EnglishName).HasMaxLength(200); builder.Property(x => x.Market).HasConversion().IsRequired().HasComment("시장 구분 (1=KOSPI, 2=KOSDAQ, 3=KONEX)"); builder.Property(x => x.TradingStatus).HasConversion().IsRequired().HasComment("거래 상태 (0=정상, 1=거래정지, 2=관리종목)"); builder.Property(x => x.CorpCode).HasMaxLength(8).IsFixedLength().HasComment("DART 고유번호"); builder.Property(x => x.SectorName).HasMaxLength(100); builder.Property(x => x.LastChangeRate).HasPrecision(7, 2); builder.Property(x => x.IssucoCustno).HasComment("SEIBro 발행회사 고객번호 (ISSUCO_CUSTNO) — 기업정보 API 조인키"); builder.Property(x => x.FaceValue).HasPrecision(15, 4).HasComment("액면가 (SEIBro PVAL)"); builder.Property(x => x.VotingRights).HasPrecision(5, 2).HasComment("1주당 의결권수 (SEIBro VOTRNO)"); builder.Property(x => x.IsElectronicSecurity).HasComment("전자증권 여부 (SEIBro ELTSC_YN)"); builder.Property(x => x.TotalIssuedShares).HasComment("총발행주식수 (SEIBro TOTAL_STK_CNT)"); } }