using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using bitforum.Models.Account;

namespace bitforum.Models.Log
{
    /// <summary>
    /// 로그인 기록
    /// </summary>
    [Table("LoginLog")]
    [Comment("로그인 기록")]
    public class LoginLog
    {
        public virtual Member Member { get; set; } = null!;

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

        [ForeignKey("MemberID")]
        [Comment("회원 ID")]
        public int? MemberID { get; set; } = null;

        [Comment("로그인 성공 여부 (0: 실패, 1: 성공)")]
        public bool Success { get; set; } = false;

        [Comment("로그인 시도한 계정")]
        [StringLength(120)]
        public string Account { get; set; } = null!;

        [Comment("실패 이유")]
        [StringLength(255)]
        public string? Reason { get; set; } = null;

        [Comment("이전 페이지 주소")]
        public string? Referer { get; set; } = null;

        [Comment("요청 주소")]
        [StringLength(500)]
        public string? Url { get; set; } = null;

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

        [Comment("User Agent")]
        [StringLength(512)]
        public string? UserAgent { get; set; } = null;

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