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

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

        [ForeignKey(nameof(BoardPrefixID))]
        public virtual BoardPrefix? BoardPrefix { get; set; }

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

        // 게시글 댓글
        public virtual List<Comment> Comment { get; set; } = [];

        // 게시글 이미지
        public virtual List<PostImage> PostImage { get; set; } = [];

        // 게시글 미디어
        public virtual List<PostMedia> PostMedia { get; set; } = [];

        // 게시글 파일
        public virtual List<PostFile> PostFile { get; set; } = [];

        // 게시글 링크
        public virtual List<PostLink> PostLink { get; set; } = [];

        // 게시글 태그
        public virtual List<PostTag> PostTag { get; set; } = [];

        // 게시글 반응
        public virtual List<PostReaction> PostReaction { get; set; } = [];

        // 게시글 즐겨찾기
        public virtual List<PostBookmark> PostBookmark { get; set; } = [];

        // 게시글 신고
        public virtual List<PostReport> PostReport { get; set; } = [];

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

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

        // 게시글 변경 기록
        public virtual List<PostUpdateLog> PostUpdateLog { get; set; } = [];

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

        public int BoardID { get; set; }

        public int? BoardPrefixID { get; set; }

        public int? MemberID { get; set; }

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

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

        public string? SID { get; set; }

        public string? Email { get; set; }

        public string? Name { get; set; }

        public string? Thumbnail { get; set; }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        public string? IpAddress { get; set; }

        public string? UserAgent { get; set; }

        public DateTime? LastReplyUpdatedAt { get; set; }

        public DateTime? LastCommentUpdatedAt { get; set; }

        public DateTime? DeletedAt { get; set; }

        public DateTime? UpdatedAt { get; set; }

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