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

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

        [ForeignKey(nameof(MemberID))]
        public virtual Member Member { 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 int MemberID { get; set; }

        [Comment("신고 사유")]
        [EnumDataType(typeof(ReportType), ErrorMessage = "{0}는 {1} 중 하나를 선택하세요.")]
        public ReportType Type { get; set; }

        [Comment("신고 내용")]
        [StringLength(1000)]
        public string? Reason { get; set; }

        [Comment("처리 상태")]
        [EnumDataType(typeof(ReportStatus), ErrorMessage = "{0}는 {1} 중 하나를 선택하세요.")]
        public ReportStatus Status { get; set; } = ReportStatus.Received;

        [Comment("처리 내용")]
        [StringLength(1000)]
        public string? Memo { get; set; }

        [Comment("IP Address")]
        [MaxLength(50)]
        public string? IpAddress { get; set; }

        [Comment("User-agent")]
        [MaxLength(255)]
        public string? UserAgent { get; set; }

        [Comment("수정 일시")]
        public DateTime? UpdatedAt { get; set; }

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