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

namespace bitforum.Models.Account
{
    [Table("EmailVerifyNumber")]
    [Comment("이메일 인증 번호들")]
    [Index(nameof(Type), Name = "IX_EmailVerifyNumber_Type")]
    [Index(nameof(Email), Name = "IX_EmailVerifyNumber_Email")]
    [Index(nameof(Code), Name = "IX_EmailVerifyNumber_Code")]
    [Index(nameof(IsVerified), Name = "IX_EmailVerifyNumber_IsVerified")]
    [Index(nameof(Expiration), Name = "IX_EmailVerifyNumber_Expiration")]
    public class EmailVerifyNumber
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Comment("PK")]
        public int ID { get; set; }

        [Comment("인증 유형 (이메일 인증 / 비밀번호 재설정)")]
        public required VerificationType Type { get; set; }

        [Comment("이메일")]
        [MaxLength(60)]
        public required string Email { get; set; }

        [Comment("Code")]
        [MaxLength(10)]
        public required string Code { get; set; }

        [Comment("인증 여부")]
        public bool IsVerified { get; set; } = false;

        [Comment("만료 일시")]
        public required DateTime Expiration { get; set; }

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