using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace Domain.Entities.Forum.Posts
{
    [Table("Tag")]
    [Index(nameof(Name), Name = "IX_Tag_Name", IsUnique = true)]
    [Index(nameof(Slug), Name = "IX_Tag_Slug", IsUnique = true)]
    [Index(nameof(UsageCount), Name = "IX_Tag_UsageCount")]
    [Index(nameof(Name), nameof(Slug), Name = "IX_Tag_Name_Slug")]
    public class Tag
    {
        public List<PostTag> PostTag { get; set; } = new List<PostTag>();

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

        [Required(ErrorMessage = "태그 명은 필수입니다.")]
        [DisplayName("태그 명")]
        [Comment("태그 명")]
        [StringLength(50, ErrorMessage = "태그는 50자 이내로 입력해주세요.")]
        public string Name { get; set; } = null!;

        [Required(ErrorMessage = "슬러그는 필수입니다.")]
        [DisplayName("슬러그")]
        [Comment("슬러그")]
        [StringLength(50, ErrorMessage = "Slug는 50자 이내로 입력해주세요.")]
        public string Slug { get; set; } = null!;

        [DisplayName("사용 횟수")]
        [Comment("사용 횟수")]
        public uint UsageCount { get; set; } = 0;

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

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