using Domain.Entities.Members;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Infrastructure.Persistence.Configurations.Members;

public sealed class MemberApproveConfiguration : IEntityTypeConfiguration<MemberApprove>
{
    public void Configure(EntityTypeBuilder<MemberApprove> builder)
    {
        builder.HasOne(x => x.Member).WithOne(x => x.MemberApprove).HasForeignKey<MemberApprove>(x => x.MemberID).OnDelete(DeleteBehavior.Cascade);

        builder.ToTable(nameof(MemberApprove), x => x.HasComment("회원 동의 및 수신 여부"));
        builder.HasKey(x => x.MemberID);
        builder.Property(x => x.MemberID).ValueGeneratedNever().HasComment("회원 ID");
        builder.Property(x => x.IsReceiveSMS).IsRequired().HasComment("SMS 수신 여부");
        builder.Property(x => x.ReceiveSMSConsentAt).HasComment("SMS 수신 동의 일시");
        builder.Property(x => x.IsReceiveEmail).IsRequired().HasComment("E-MAIL 수신 여부");
        builder.Property(x => x.ReceiveEmailConsentAt).HasComment("E-MAIL 수신 동의 일시");
        builder.Property(x => x.IsReceiveNote).IsRequired().HasComment("쪽지 수신 여부");
        builder.Property(x => x.ReceiveNoteConsentAt).HasComment("쪽지 수신 동의 일시");
        builder.Property(x => x.IsDisclosureInvest).IsRequired().HasComment("투자 현황 공개 여부");
        builder.Property(x => x.DisclosureInvestConsentAt).HasComment("투자 현황 공개 동의 일시");
    }
}