| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- using Domain.Entities.Store;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- namespace Infrastructure.Persistence.Configurations.Store;
- public sealed class ProductConfiguration : IEntityTypeConfiguration<Product>
- {
- public void Configure(EntityTypeBuilder<Product> builder)
- {
- builder.ToTable(nameof(Product), t => t.HasComment("상점 상품"));
- builder.HasKey(x => x.ID);
- builder.HasOne(x => x.Game).WithMany().HasForeignKey(x => x.GameID).IsRequired(false).OnDelete(DeleteBehavior.Restrict);
- builder.Property(x => x.GameID).HasComment("게임 ID (선택 — null=플랫폼 직접판매)");
- builder.Property(x => x.Name).HasMaxLength(200).IsRequired().HasComment("상품명");
- builder.Property(x => x.Description).HasColumnType("nvarchar(max)");
- builder.Property(x => x.Thumbnail).HasMaxLength(500);
- builder.Property(x => x.Type).HasConversion<int>().IsRequired().HasComment("상품 유형 (1=Physical, 2=Digital)");
- builder.Property(x => x.Price).IsRequired().HasComment("판매가 (KRW)");
- builder.Property(x => x.Stock).IsRequired().HasComment("재고 (-1=무제한)");
- builder.Property(x => x.MinPurchase).IsRequired().HasDefaultValue(1).HasComment("1회 주문 최소 구매 수량");
- builder.Property(x => x.MaxPurchase).IsRequired().HasDefaultValue(999).HasComment("1회 주문 최대 구매 수량 (하드 상한 999)");
- builder.Property(x => x.RequireDonationChannel).IsRequired().HasDefaultValue(false).HasComment("구매 시 후원 채널 선택 필수 여부");
- builder.Property(x => x.ItemKind).HasComment("소모품 종류 (null=일반상품, 5~11=소모품)");
- builder.Property(x => x.DurationDays).IsRequired().HasDefaultValue(0).HasComment("소모품 효과 지속일 (0=즉시소모)");
- builder.Property(x => x.IsActive).IsRequired();
- builder.Property(x => x.Order).IsRequired();
- builder.Property(x => x.SaleStartAt);
- builder.Property(x => x.SaleEndAt);
- builder.Property(x => x.CreatedAt).IsRequired();
- builder.Property(x => x.UpdatedAt);
- builder.Property(x => x.RowVersion).IsRowVersion();
- builder.HasIndex(x => new { x.GameID, x.IsActive, x.Order });
- builder.HasIndex(x => new { x.IsActive, x.Type });
- builder.HasIndex(x => new { x.ItemKind, x.IsActive });
- }
- }
|