package ru.kirillius.pf.sdn.entity;

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

import java.util.HashMap;
import java.util.Map;

@Entity
@Table(name = "subscription_provider_config")
@Getter
@Setter
@NoArgsConstructor
@Builder
@AllArgsConstructor
public class SubscriptionProviderConfig {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false, unique = true)
    private String name;

    @Column(nullable = false)
    private String protocolId;

    @ElementCollection(fetch = FetchType.EAGER)  // Подгружать сразу
    @CollectionTable(
            name = "subscription_provider_config_properties",
            joinColumns = @JoinColumn(name = "config_id")
    )
    @MapKeyColumn(name = "prop_key")
    @Column(name = "prop_value")
    private Map<String, String> properties = new HashMap<>();

    @Column(nullable = false)
    private String shellScriptBefore;

    @Column(nullable = false)
    private String shellScriptAfter;
}
