package com.pharmacopoeia.entity;

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

import java.time.Instant;
import java.util.List;

@Entity
@Table(name = "drug_chunks")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DrugChunk {

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

    @Column(name = "drug_id", nullable = false)
    private String drugId;

    private String section;

    @Column(columnDefinition = "text", nullable = false)
    private String content;

    @Column(columnDefinition = "text")
    private String source;

    @Column(name = "chunk_index")
    private Integer chunkIndex;

    @Column(columnDefinition = "vector(1024)", insertable = false, updatable = false)
    private List<Float> vec;

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

    @PrePersist
    void prePersist() {
        createdAt = Instant.now();
    }
}
