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("CommentLink")]
    [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 CommentLink
    {
        [ForeignKey(nameof(BoardID))]
        public virtual Board Board { get; set; } = default!;

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

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

        [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("링크 ID")]
        public Guid UUID { get; set; }

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

        [Comment("클릭 수")]
        [Range(0, int.MaxValue)]
        public int Clicks { get; set; } = 0;

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

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

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