using Domain.Entities.Store; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Store; public sealed class ShipmentConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(Shipment), t => t.HasComment("배송 (주문 시점 주소 스냅샷, 암호화)")); builder.HasKey(x => x.ID); builder.HasOne(x => x.Order).WithOne().HasForeignKey(x => x.OrderID).OnDelete(DeleteBehavior.Cascade); builder.Property(x => x.OrderID).IsRequired(); builder.Property(x => x.RecipientName_Encrypted).IsRequired(); builder.Property(x => x.Phone_Encrypted).IsRequired(); builder.Property(x => x.ZipCode).HasMaxLength(10).IsRequired(); builder.Property(x => x.Address1_Encrypted).IsRequired(); builder.Property(x => x.Address2_Encrypted).IsRequired(); builder.Property(x => x.KeyVersion).IsRequired(); builder.Property(x => x.Status).HasConversion().IsRequired(); builder.Property(x => x.Carrier).HasMaxLength(50); builder.Property(x => x.TrackingNumber).HasMaxLength(50); builder.Property(x => x.ShippingFee).HasDefaultValue(0).IsRequired(); builder.Property(x => x.AdminMemo).HasMaxLength(500); builder.Property(x => x.CreatedAt).IsRequired(); builder.Property(x => x.ShippedAt); builder.Property(x => x.DeliveredAt); builder.HasIndex(x => x.OrderID).IsUnique(); builder.HasIndex(x => x.Status); builder.HasIndex(x => x.TrackingNumber); } }