InterestRateConfiguration.cs 1.0 KB

1234567891011121314151617181920
  1. using Domain.Entities.Stocks;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Stocks;
  5. public sealed class InterestRateConfiguration : IEntityTypeConfiguration<InterestRate>
  6. {
  7. public void Configure(EntityTypeBuilder<InterestRate> builder)
  8. {
  9. builder.ToTable(nameof(InterestRate), t => t.HasComment("일별 금리 (한국수출입은행 OpenAPI AP02 대출금리 / AP03 국제금리)"));
  10. builder.HasKey(x => x.ID);
  11. builder.HasIndex(x => new { x.RateType, x.ItemName, x.TradeDate }).IsUnique();
  12. builder.HasIndex(x => x.TradeDate);
  13. builder.Property(x => x.RateType).HasConversion<byte>().IsRequired().HasComment("금리 종류 (1=대출금리, 2=국제금리)");
  14. builder.Property(x => x.ItemName).HasMaxLength(100).IsRequired().HasComment("항목명 (cur_nm 등)");
  15. builder.Property(x => x.Rate).HasPrecision(9, 4).HasComment("금리 % — 미고시 시 null");
  16. }
  17. }