package com.agent.management.model.entity;

import com.agent.management.rag.model.RagSourceType;
import jakarta.persistence.*;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "rag_query_example", indexes = @Index(name = "idx_rag_example_source", columnList = "source_type,source_id"))
public class RagQueryExample {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
    @Enumerated(EnumType.STRING) @Column(name = "source_type", nullable = false) private RagSourceType sourceType;
    @Column(name = "source_id", nullable = false) private String sourceId;
    @Column(nullable = false, length = 1000) private String question;
    @Column(name = "query_text", nullable = false, columnDefinition = "TEXT") private String queryText;
    @Column(name = "schema_version", length = 64) private String schemaVersion;
    private boolean verified = true;
    @Column(name = "success_count") private long successCount = 1;
    @Column(name = "created_at") private LocalDateTime createdAt;
    @Column(name = "updated_at") private LocalDateTime updatedAt;
    @PrePersist void create(){createdAt=updatedAt=LocalDateTime.now();}
    @PreUpdate void update(){updatedAt=LocalDateTime.now();}
}
