using Domain.Entities.Store; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Store; public sealed class ProductLimitConfigConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(ProductLimitConfig), t => t.HasComment("상품 판매 정책 (1:1 with Product)")); builder.HasKey(x => x.ProductID); builder.HasOne(x => x.Product).WithOne().HasForeignKey(x => x.ProductID).OnDelete(DeleteBehavior.Cascade); builder.Property(x => x.ProductID).ValueGeneratedNever(); builder.Property(x => x.UseQuantityLimit).IsRequired().HasComment("수량 제한 사용 여부"); builder.Property(x => x.MaxQuantity).IsRequired().HasComment("회원당 누적 최대 구매 수량 (0=무제한)"); builder.Property(x => x.UsePeriodLimit).IsRequired().HasComment("기간 제한 사용 여부"); builder.Property(x => x.PeriodType).HasConversion().IsRequired().HasComment("기간 유형 (0=None, 1=Day, 2=Week, 3=Month, 4=Custom)"); builder.Property(x => x.PeriodStartAt).HasComment("Custom 시 절대 윈도우 시작 시각 (UTC)"); builder.Property(x => x.PeriodEndAt).HasComment("Custom 시 절대 윈도우 종료 시각 (UTC)"); builder.Property(x => x.UpdatedAt); builder.Property(x => x.CreatedAt).IsRequired(); } }