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

namespace Infrastructure.Persistence.Configurations.Members;

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

        builder.ToTable(nameof(MemberStats), x => x.HasComment("회원 활동 집계"));
        builder.HasKey(x => x.MemberID);
        builder.Property(x => x.MemberID).ValueGeneratedNever().HasComment("회원 ID");
        builder.Property(x => x.RowVersion).IsRowVersion().HasComment("동시성");
        builder.Property(x => x.Exp).IsRequired().HasComment("경험치");
        builder.Property(x => x.PostCount).IsRequired().HasComment("작성 게시글");
        builder.Property(x => x.CommentCount).IsRequired().HasComment("작성 댓글");
        builder.Property(x => x.LikeReceivedCount).IsRequired().HasComment("받은 좋아요 수");
        builder.Property(x => x.LikeGivenCount).IsRequired().HasComment("누른 좋아요 수");
        builder.Property(x => x.ReportedCount).IsRequired().HasComment("신고 당한 횟수");
        builder.Property(x => x.BookmarkGivenCount).IsRequired().HasComment("즐겨찾기 글 수");
        builder.Property(x => x.WarningCount).IsRequired().HasComment("경고 횟수");
        builder.Property(x => x.SuspensionCount).IsRequired().HasComment("정지 횟수");
        builder.Property(x => x.LoginCount).IsRequired().HasComment("로그인");
        builder.Property(x => x.AttendanceCount).IsRequired().HasComment("출석");
        builder.Property(x => x.FollowingCount).IsRequired().HasComment("구독 중");
        builder.Property(x => x.FollowerCount).IsRequired().HasComment("구독자");
        builder.Property(x => x.PaymentCount).IsRequired().HasComment("결제 횟수");
        builder.Property(x => x.TotalPaidAmount).IsRequired().HasComment("누적 결제 금액");
        builder.Property(x => x.TotalCanceledAmount).IsRequired().HasComment("누적 취소/환불 금액");
    }
}