package com.magistr.app.model;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import java.time.Instant;

@Entity
@Table(name = "auth_login_attempt_audit")
public class AuthLoginAttemptAudit {

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

    @Column(nullable = false, length = 100)
    private String tenant;

    @Column(name = "username_normalized", nullable = false, length = 100)
    private String usernameNormalized;

    @Column(name = "client_ip", nullable = false, length = 64)
    private String clientIp;

    @Column(nullable = false, length = 20)
    private String outcome;

    @Column(name = "occurred_at", nullable = false)
    private Instant occurredAt;

    @Column(name = "retry_after_seconds")
    private Integer retryAfterSeconds;

    public AuthLoginAttemptAudit() {
    }

    public AuthLoginAttemptAudit(String tenant,
                                 String usernameNormalized,
                                 String clientIp,
                                 String outcome,
                                 Instant occurredAt,
                                 Integer retryAfterSeconds) {
        this.tenant = tenant;
        this.usernameNormalized = usernameNormalized;
        this.clientIp = clientIp;
        this.outcome = outcome;
        this.occurredAt = occurredAt;
        this.retryAfterSeconds = retryAfterSeconds;
    }

    public String getTenant() {
        return tenant;
    }

    public String getUsernameNormalized() {
        return usernameNormalized;
    }

    public String getClientIp() {
        return clientIp;
    }

    public String getOutcome() {
        return outcome;
    }

    public Instant getOccurredAt() {
        return occurredAt;
    }

    public Integer getRetryAfterSeconds() {
        return retryAfterSeconds;
    }
}
