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

namespace Domain.Entities.Forum.Comments
{
    [Table("CommentMention")]
    [Index(nameof(BoardID))]
    [Index(nameof(PostID))]
    [Index(nameof(MemberID))]
    [Index(nameof(CommentID))]
    [Index(nameof(CommentID), nameof(ID))]
    [Index(nameof(CommentID), nameof(MemberID), nameof(ID))]
    [Index(nameof(CommentID), nameof(MemberID), nameof(Start), IsUnique = true)]
    public class CommentMention
    {
        [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!;

        [ForeignKey(nameof(MemberID))]
        public virtual Member Member { 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("언급된 회원 ID")]
        public int MemberID { get; set; }

        [Comment("원문 회원 언급값")]
        [MaxLength(64)]
        public string RawHandle { get; set; } = null!;

        [Comment("본문 내 시작 인덱스")]
        public int Start { get; set; } = -1;

        [Comment("길이")]
        public int Length { get; set; }

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