package gc.mda.kcg.domain.satellite;

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

import java.time.Instant;

@Entity
@Table(name = "satellite_tle", schema = "kcg")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SatelliteTle {

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

    @Column(name = "norad_id", nullable = false)
    private Integer noradId;

    @Column(nullable = false, length = 128)
    private String name;

    @Column(name = "tle_line1", nullable = false, length = 70)
    private String tleLine1;

    @Column(name = "tle_line2", nullable = false, length = 70)
    private String tleLine2;

    @Column(length = 20)
    private String category;

    @Column(name = "tle_group", length = 32)
    private String tleGroup;

    private Instant epoch;

    @Column(name = "collected_at", nullable = false)
    private Instant collectedAt;

    @PrePersist
    protected void onCreate() {
        if (collectedAt == null) {
            collectedAt = Instant.now();
        }
    }
}
