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

namespace bitforum.Models.Page.Faq
{
    [Table("FaqCategory")]
    [Index(nameof(Code), Name = "IX_FaqCategory_Code", IsUnique = true)]
    [Index(nameof(Order), Name = "IX_FaqCategory_Order")]
    public class FaqCategory
    {
        public virtual List<FaqItem> FaqItem { get; set; } = new List<FaqItem>();

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

        [Required]
        [DisplayName("주소")]
        [Comment("주소")]
        [DataType(DataType.Text)]
        [StringLength(30)]
        [RegularExpression(@"^[a-zA-Z0-9]+$", ErrorMessage = "주소는 영문 및 숫자로만 구성되어야 합니다.")]
        public string Code { get; set; } = null!;

        [Required]
        [DisplayName("분류 명")]
        [Comment("분류 명")]
        [DataType(DataType.Text)]
        [StringLength(255)]
        public string Subject { get; set; } = null!;

        [Required]
        [DisplayName("순서")]
        [Comment("순서")]
        public int Order { get; set; } = 0;

        [Required]
        [DisplayName("사용 여부")]
        [Comment("사용 여부")]
        public bool IsActive { get; set; } = false;

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

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