package com.iqser.red.service.persistence.management.v1.processor.entity.audit;

import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;

import jakarta.persistence.Basic;
import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import com.iqser.red.service.persistence.management.v1.processor.utils.JSONMapConverter;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "audit")
public class AuditEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long recordId;

    @Column
    private OffsetDateTime recordDate;

    @Column
    private String objectId;
    @Column
    private String category;
    @Column
    private String userId;
    @Column(length = 4000)
    private String message;

    @Basic(fetch = FetchType.EAGER)
    @Column(columnDefinition = "text")
    @Convert(converter = JSONMapConverter.class)
    private Map<String, Object> details = new HashMap<>();

}
