package com.pharmacopoeia.entity;

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

import java.time.Instant;

@Entity
@Table(name = "quick_ask_audit_log")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class QuickAskAuditLog {

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

    @Column(name = "quick_ask_id", nullable = false)
    private Integer quickAskId;

    @Column(nullable = false, length = 16)
    private String action;

    @Column(length = 64)
    private String label;

    @Column(length = 256)
    private String question;

    @Column(name = "sort_order")
    @Builder.Default
    private Integer sortOrder = 0;

    @Column(name = "is_active")
    @Builder.Default
    private Boolean isActive = true;

    @Column(nullable = false, length = 255)
    private String operator;

    @Column(length = 45)
    private String ip;

    @Column(name = "created_at", updatable = false)
    private Instant createdAt;

    @PrePersist
    void onCreate() {
        if (createdAt == null) createdAt = Instant.now();
    }
}
