using Domain.Entities.Forum.Boards;
using Domain.Entities.Forum.Posts;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Domain.Entities.Forum.Comments
{
    [Table("CommentMedia")]
    [Index(nameof(BoardID))]
    [Index(nameof(PostID))]
    [Index(nameof(CommentID))]
    [Index(nameof(Url))]
    [Index(nameof(CommentID), nameof(ID))]
    [Index(nameof(CommentID), nameof(IsDisabled), nameof(ID))]
    public class CommentMedia
    {
        [ForeignKey(nameof(BoardID))]
        public virtual Board Board { get; set; } = null!;

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

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

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Comment("PK")]
        public int ID { get; set; }

        [Comment("게시판 ID")]
        public int BoardID { get; set; }

        [Comment("게시글 ID")]
        public int PostID { get; set; }

        [Comment("댓글 ID")]
        public int CommentID { get; set; }

        [Comment("URL")]
        [StringLength(1000)]
        public string Url { get; set; } = null!;

        [Comment("비활성 여부")]
        public bool IsDisabled { get; set; } = false;

        [Comment("비활성 일시")]
        public DateTime? DisabledAt { get; set; }

        [Comment("등록 일시")]
        public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
    }
}