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

namespace bitforum.Models
{
    [Table("Config")]
    [Index(nameof(Key), IsUnique = true)]
    public class Config
    {
        [Key]
        public int ID { get; set; }

        [Required]
        public string Key { get; set; }
        public string? Value { get; set; }
        public string? Description { get; set; }
        public DateTime CreatedAt { get; set; } = DateTime.Now;
    }

    // 기본 정보
    public class BasicForm
    {
        [Display(Name = "사이트 이름")]
        [BindProperty(Name = "site_name")]
        public string? SiteName { get; set; } = null;

        [Display(Name = "최고 관리자")]
        [BindProperty(Name = "root_id")]
        public string? RootID { get; set; } = null;

        [Display(Name = "송수신 이메일")]
        [BindProperty(Name = "from_email")]
        public string? FromEmail { get; set; } = null;

        [Display(Name = "송수신자 이름")]
        [BindProperty(Name = "from_email_name")]
        public string? FromEmailName { get; set; } = null;

        [Display(Name = "SMTP Server")]
        [BindProperty(Name = "smtp_server")]
        public string? SmtpServer { get; set; } = null;

        [Display(Name = "SMTP Port")]
        [BindProperty(Name = "smtp_port")]
        public string? SmtpPort { get; set; } = null;

        [Display(Name = "SMTP From Email")]
        [BindProperty(Name = "smtp_from_email")]
        public string? SmtpFromEmail { get; set; } = null;

        [Display(Name = "SMTP Email Password")]
        [BindProperty(Name = "smtp_email_password")]
        public string? SmtpEmailPassword { get; set; } = null;

        [Display(Name = "관리자단 접근 가능 IP")]
        [BindProperty(Name = "admin_white_ip_list")]
        public string? AdminWhiteIPList { get; set; } = null;

        [Display(Name = "사용자단 접근 가능 IP")]
        [BindProperty(Name = "front_white_ip_list")]
        public string? FrontWhiteIPList { get; set; } = null;

        [Display(Name = "차단 시 안내문 제목")]
        [BindProperty(Name = "block_alert_title")]
        public string? BlockAlertTitle { get; set; } = null;

        [Display(Name = "차단 시 안내문 내용")]
        [BindProperty(Name = "block_alert_content")]
        public string? BlockAlertContent { get; set; } = null;

        [Display(Name = "점검 여부")]
        [BindProperty(Name = "is_maintenance")]
        [RegularExpression("^[01]$", ErrorMessage = "점검 여부는 0 또는 1이어야 합니다.")]
        public char IsMaintenance { get; set; } = '0';

        [Display(Name = "점검 내용")]
        [BindProperty(Name = "maintenance_content")]
        public string? MaintenanceContent { get; set; } = null;
    }

    // 메타 태그
    public class MetaForm
    {
        [Display(Name = "Meta Keywords")]
        [BindProperty(Name = "meta_keywords")]
        public string? MetaKeyword { get; set; } = null;

        [Display(Name = "Meta Description")]
        [BindProperty(Name = "meta_description")]
        public string? MetaDescription { get; set; } = null;

        [Display(Name = "Meta Author")]
        [BindProperty(Name = "meta_author")]
        public string? MetaAuthor { get; set; } = null;

        [Display(Name = "Meta Viewport")]
        [BindProperty(Name = "meta_viewport")]
        public string? MetaViewport { get; set; } = null;

        [Display(Name = "Meta Application Name")]
        [BindProperty(Name = "meta_application_name")]
        public string? MetaApplicationName { get; set; } = null;

        [Display(Name = "Meta Generator")]
        [BindProperty(Name = "meta_generator")]
        public string? MetaGenerator { get; set; } = null;

        [Display(Name = "Meta Robots")]
        [BindProperty(Name = "meta_robots")]
        public string? MetaRobots { get; set; } = null;

        [Display(Name = "Meta Adds")]
        [BindProperty(Name = "meta_adds")]
        public string? MetaAdds { get; set; } = null;
    }

    // 회사 정보
    public class CompanyForm
    {
        [Display(Name = "상호 명")]
        [BindProperty(Name = "company_name")]
        public string? CompanyName { get; set; } = null;

        [Display(Name = "사업자 등록 번호")]
        [BindProperty(Name = "company_reg_no")]
        public string? CompanyRegNo { get; set; } = null;

        [Display(Name = "대표자 명")]
        [BindProperty(Name = "company_owner")]
        public string? CompanyOwner { get; set; } = null;

        [Display(Name = "대표 전화번호")]
        [BindProperty(Name = "company_tel")]
        public string? CompanyTel { get; set; } = null;

        [Display(Name = "FAX 번호")]
        [BindProperty(Name = "company_fax")]
        public string? CompanyFax { get; set; } = null;

        [Display(Name = "통신판매업 신고번호")]
        [BindProperty(Name = "company_retail_sale_no")]
        public string? CompanyRetailSaleNo { get; set; } = null;

        [Display(Name = "부가통신 사업자번호")]
        [BindProperty(Name = "company_added_sale_no")]
        public string? CompanyAddedSaleNo { get; set; } = null;

        [Display(Name = "사업장 주소")]
        [BindProperty(Name = "company_zip_code")]
        public string? CompanyZipCode { get; set; } = null;

        [Display(Name = "호스팅 서비스")]
        [BindProperty(Name = "company_hosting")]
        public string? CompanyHosting { get; set; } = null;

        [Display(Name = "정보관리책임자")]
        [BindProperty(Name = "company_admin_name")]
        public string? CompanyAdminName { get; set; } = null;

        [Display(Name = "정보관리책임자 E-mail")]
        [BindProperty(Name = "company_admin_email")]
        public string? CompanyAdminEmail { get; set; } = null;

        [Display(Name = "사이트 주소")]
        [BindProperty(Name = "company_site_url")]
        public string? CompanySiteURL { get; set; } = null;

        [Display(Name = "입금 계좌")]
        [BindProperty(Name = "company_bank_code")]
        public int? CompanyBankCode { get; set; }

        [Display(Name = "예금주")]
        [BindProperty(Name = "company_bank_owner")]
        public string? CompanyBankOwner { get; set; } = null;

        [Display(Name = "계좌번호")]
        [BindProperty(Name = "company_bank_number")]
        public string? CompanyBankNumber { get; set; } = null;
    }

    // 회원가입 설정
    public class RegisterForm
    {
        [Display(Name = "회원가입 차단")]
        [BindProperty(Name = "is_register_block")]
        public bool IsRegisterBlock { get; set; } = false;

        [Display(Name = "회원가입 시 이메일 인증")]
        [BindProperty(Name = "register_able")]
        public bool IsRegisterEmailAuth { get; set; } = false;

        [Display(Name = "비밀번호 최소 길이")]
        [BindProperty(Name = "password_min_length")]
        public int? PasswordMinLength { get; set; } = null;

        [Display(Name = "비밀번호 최소 대문자 수")]
        [BindProperty(Name = "password_uppercase_length")]
        public int? PasswordUppercaseLength { get; set; } = null;

        [Display(Name = "비밀번호 최소 숫자 수")]
        [BindProperty(Name = "password_numbers_length")]
        public int? PasswordNumbersLength { get; set; } = null;

        [Display(Name = "비밀번호 최소 특수문자 수")]
        [BindProperty(Name = "password_specialchars_length")]
        public int? PasswordSpecialcharsLength { get; set; } = null;

        [Display(Name = "금지 별명")]
        [BindProperty(Name = "denied_nickname_list")]
        public string? DeniedNicknameList { get; set; } = null; 

        [Display(Name = "별명 갱신 주기")]
        [BindProperty(Name = "change_nickname_day")]
        public int? ChangeNicknameDay { get; set; } = null;

        [Display(Name = "이메일 갱신 주기")]
        [BindProperty(Name = "change_email_day")]
        public int? ChangeEmailDay { get; set; } = null;

        [Display(Name = "비밀번호 갱신 주기")]
        [BindProperty(Name = "change_password_day")]
        public int? ChangePasswordDay { get; set; } = null;

        [Display(Name = "로그인 시도 제한 횟수")]
        [BindProperty(Name = "max_login_try_count")]
        public int? MaxLoginTryCount { get; set; } = null;

        [Display(Name = "로그인 시도 제한 시간")]
        [BindProperty(Name = "max_login_try_limit_second")]
        public int? MaxLoginTryLimitSecond { get; set; } = null;
    }
}
