package com.smyhub.infogenie.infogeniebackendjava.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

/**
 * Maps to the ai_configs table.
 * Stores per-provider API credentials and model lists loaded from the database.
 * Mirrors the Go model of the same name.
 */
@Data
@NoArgsConstructor
@Entity
@Table(name = "ai_configs")
public class AIConfig {

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

    @Column(unique = true, nullable = false, length = 50)
    private String provider;

    @Column(name = "api_key", length = 500)
    private String apiKey;

    @Column(name = "api_base", length = 500)
    private String apiBase;

    @Column(name = "default_model", length = 100)
    private String defaultModel;

    /**
     * Comma-separated or JSON-encoded model list stored as TEXT in MySQL.
     */
    @Column(columnDefinition = "TEXT")
    private String models;

    @Column(name = "is_enabled")
    private Boolean isEnabled = true;

    @UpdateTimestamp
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;
}
