using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using FacebookService.Domain.AggregatesModel.ChatbotAggregate;

namespace FacebookService.Infrastructure.EntityConfigurations;

/// <summary>
/// EN: EF Core configuration for FlowTriggerType enumeration.
/// VI: Cấu hình EF Core cho enumeration FlowTriggerType.
/// </summary>
public class FlowTriggerTypeEntityTypeConfiguration : IEntityTypeConfiguration<FlowTriggerType>
{
    public void Configure(EntityTypeBuilder<FlowTriggerType> builder)
    {
        builder.ToTable("flow_trigger_types");
        builder.HasKey(t => t.Id);
        builder.Property(t => t.Id).ValueGeneratedNever();
        builder.Property(t => t.Name).HasMaxLength(50).IsRequired();

        // EN: Seed data / VI: Dữ liệu khởi tạo
        builder.HasData(
            FlowTriggerType.GetStarted,
            FlowTriggerType.Keyword,
            FlowTriggerType.Postback,
            FlowTriggerType.Fallback
        );
    }
}

/// <summary>
/// EN: EF Core configuration for NodeType enumeration.
/// VI: Cấu hình EF Core cho enumeration NodeType.
/// </summary>
public class NodeTypeEntityTypeConfiguration : IEntityTypeConfiguration<NodeType>
{
    public void Configure(EntityTypeBuilder<NodeType> builder)
    {
        builder.ToTable("node_types");
        builder.HasKey(t => t.Id);
        builder.Property(t => t.Id).ValueGeneratedNever();
        builder.Property(t => t.Name).HasMaxLength(50).IsRequired();

        // EN: Seed data / VI: Dữ liệu khởi tạo
        builder.HasData(
            NodeType.Start,
            NodeType.Message,
            NodeType.Question,
            NodeType.Condition,
            NodeType.Action,
            NodeType.End
        );
    }
}

/// <summary>
/// EN: EF Core configuration for AIProvider enumeration.
/// VI: Cấu hình EF Core cho enumeration AIProvider.
/// </summary>
public class AIProviderEntityTypeConfiguration : IEntityTypeConfiguration<AIProvider>
{
    public void Configure(EntityTypeBuilder<AIProvider> builder)
    {
        builder.ToTable("ai_providers");
        builder.HasKey(p => p.Id);
        builder.Property(p => p.Id).ValueGeneratedNever();
        builder.Property(p => p.Name).HasMaxLength(50).IsRequired();

        // EN: Seed data / VI: Dữ liệu khởi tạo
        builder.HasData(
            AIProvider.OpenAI,
            AIProvider.AzureOpenAI
        );
    }
}
