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

namespace Domain.Entities.Forum.Posts
{
    [Table("PostReport")]
    [Index(nameof(BoardID))]
    [Index(nameof(PostID))]
    [Index(nameof(MemberID))]
    [Index(nameof(Type))]
    [Index(nameof(Status))]
    [Index(nameof(PostID), nameof(MemberID), IsUnique = true)]
    public class PostReport
    {
        [ForeignKey(nameof(BoardID))]
        public Board Board { get; set; } = null!;

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

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

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

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

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

        [DisplayName("회원 ID")]
        [Comment("회원 ID")]
        public int MemberID { get; set; }

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

        [DisplayName("신고 내용")]
        [Comment("신고 내용")]
        [StringLength(1000, ErrorMessage = "{0}은 {1}자 이하로 입력하세요.")]
        public string? Reason { get; set; } = null;

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

        [DisplayName("처리 내용")]
        [Comment("처리 내용")]
        [StringLength(1000, ErrorMessage = "{0}은 {1}자 이하로 입력하세요.")]
        public string? Memo { get; set; } = null;

        [DisplayName("IP Address")]
        [Comment("IP Address")]
        [MaxLength(15)]
        public string? IpAddress { get; set; } = null;

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

        [DisplayName("수정 일시")]
        [Comment("수정 일시")]
        [DataType(DataType.DateTime)]
        public DateTime? UpdatedAt { get; set; } = null;

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