using Domain.Entities.Page.Banner;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Infrastructure.Persistence.Configurations.Page.Banner;

public sealed class BannerItemConfiguration : IEntityTypeConfiguration<BannerItem>
{
    public void Configure(EntityTypeBuilder<BannerItem> builder)
    {
        builder.HasIndex(x => x.PositionID);
        builder.HasIndex(x => x.Order);
        builder.HasIndex(x => x.IsActive);
        builder.HasIndex(x => new { x.PositionID, x.Order, x.IsActive });

        builder.ToTable(nameof(BannerItem), t => t.HasComment("배너 아이템"));
        builder.HasKey(x => x.ID);
        builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
        builder.Property(x => x.PositionID).IsRequired().HasComment("배너 위치 ID");
        builder.Property(x => x.Subject).HasMaxLength(255).IsRequired().HasComment("배너 명");
        builder.Property(x => x.DesktopImage).HasMaxLength(1024).HasComment("이미지(Desktop)");
        builder.Property(x => x.MobileImage).HasMaxLength(1024).HasComment("이미지(Mobile)");
        builder.Property(x => x.Link).HasMaxLength(255).HasComment("주소");
        builder.Property(x => x.Order).IsRequired().HasComment("순서");
        builder.Property(x => x.IsActive).IsRequired().HasComment("사용 여부");
        builder.Property(x => x.StartAt).HasComment("사용 기간 - 시작");
        builder.Property(x => x.EndAt).HasComment("사용 기간 - 종료");
        builder.Property(x => x.UpdatedAt).HasComment("수정 일시");
        builder.Property(x => x.CreatedAt).IsRequired().HasComment("등록 일시");
    }
}