using Domain.Entities.Forum.ValueObject;
using Domain.Entities.Forum.Boards;
using Domain.Entities.Forum.Posts;
using Domain.Entities.Forum.Logs;
using Domain.Entities.Members;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Domain.Entities.Forum.Comments
{
    public class Comment
    {
        [ForeignKey(nameof(BoardID))]
        public virtual Board Board { get; set; } = null!;

        [ForeignKey(nameof(PostID))]
        public virtual Post Post { get; set; } = null!;

        [ForeignKey(nameof(MemberID))]
        public virtual Member Member { get; set; } = null!;

        [ForeignKey(nameof(MentionMemberID))]
        public virtual Member? MentionMember { get; set; }

        public virtual Comment? Parent { get; set; }
        public virtual ICollection<Comment> Children { get; set; } = [];

        // 댓글 이미지
        public virtual List<CommentImage> CommentImage { get; set; } = [];

        // 댓글 미디어
        public virtual List<CommentMedia> CommentMedia { get; set; } = [];

        // 댓글 파일
        public virtual List<CommentFile> CommentFile { get; set; } = [];

        // 댓글 링크
        public virtual List<CommentLink> CommentLink { get; set; } = [];

        // 댓글 좋아요/싫어요
        public virtual List<CommentReaction> CommentReaction { get; set; } = [];

        // 댓글 신고
        public virtual List<CommentReport> CommentReport { get; set; } = [];

        // 댓글 파일 다운로드 기록
        public virtual List<CommentFileDownLog> CommentFileDownLog { get; set; } = [];

        // 댓글 링크 클릭 기록
        public virtual List<CommentLinkClickLog> CommentLinkClickLog { get; set; } = [];

        // 댓글 변경 기록
        public virtual List<CommentUpdateLog> CommentUpdateLog { get; set; } = [];

        // 답글 언급
        public virtual CommentMention? CommentMention { get; set; }

        [Key]
        public int ID { get; set; }

        public int BoardID { get; set; }

        public int PostID { get; set; }

        public int MemberID { get; set; }

        public int? ParentID { get; set; }

        public int? MentionMemberID { get; set; }

        public sbyte Depth { get; set; } = 0;

        public string Content { get; set; } = default!;

        public string SID { get; set; } = default!;

        public string Email { get; set; } = default!;

        public string? Name { get; set; }

        public bool IsReply { get; set; } = false;

        public bool IsSecret { get; set; } = false;

        public bool IsDeleted { get; set; } = false;

        public int Likes { get; set; } = 0;

        public int Dislikes { get; set; } = 0;

        public int Reports { get; set; } = 0;

        public int Replies { get; set; } = 0;

        public int Score { get; set; } = 0;

        public int Images { get; set; } = 0;

        public byte Medias { get; set; } = 0;

        public byte Files { get; set; } = 0;

        public string? IpAddress { get; set; }

        public string? UserAgent { get; set; }

        public DisplayStatus Status { get; set; } = DisplayStatus.Normal;

        public DateTime? DeletedAt { get; set; }

        public DateTime? UpdatedAt { get; set; }

        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
    }
}