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

namespace Infrastructure.Persistence.Configurations.Page.Faq;

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

        builder.ToTable(nameof(FaqItem), t => t.HasComment("FAQ 목록"));
        builder.HasKey(x => x.ID);
        builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
        builder.Property(x => x.CategoryID).IsRequired().HasComment("분류 ID");
        builder.Property(x => x.Question).HasMaxLength(255).IsRequired().HasComment("질문");
        builder.Property(x => x.Answer).HasMaxLength(4000).HasComment("답변");
        builder.Property(x => x.Order).IsRequired().HasComment("순서");
        builder.Property(x => x.IsActive).IsRequired().HasComment("사용 여부");
        builder.Property(x => x.UpdatedAt).HasComment("수정 일시");
        builder.Property(x => x.CreatedAt).IsRequired().HasComment("등록 일시");
    }
}