package kr.co.accura.wbx.spring.auth;

import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDateTime;

@Entity
@Table(name = "wbx_login_history")
@Getter @Setter
@NoArgsConstructor @AllArgsConstructor @Builder
public class WbxLoginHistory {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "user_id")
    private Long userId;

    private String email;

    @Column(nullable = false, length = 20)
    private String action; // LOGIN_SUCCESS, LOGIN_FAILURE, LOGOUT, MFA_SUCCESS, MFA_FAILURE

    @Column(name = "ip_address", length = 50)
    private String ipAddress;

    @Column(name = "user_agent", length = 500)
    private String userAgent;

    @Column(name = "auth_method", length = 20)
    private String authMethod; // PASSWORD, SSO, API_KEY, REFRESH_TOKEN

    @Column(name = "failure_reason", length = 200)
    private String failureReason;

    @Builder.Default
    @Column(name = "created_at", updatable = false)
    private LocalDateTime createdAt = LocalDateTime.now();
}
