package space.nstart.pcp_tgu_service.entity

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import java.time.LocalDateTime
import space.nstart.pcp.pcp_types_lib.utils.UtcDateTimes

/**
 * Persisted snapshot КА из НСИ, используемый как вход для refresh jobs.
 */
@Entity
@Table(name = "spacecraft_snapshot")
class SpacecraftSnapshotEntity(
    @Id
    @Column(name = "spacecraft_id", nullable = false, updatable = false)
    var spacecraftId: String,

    @Column(name = "norad_id", nullable = false)
    var noradId: Long,

    @Column(name = "nsi_id")
    var nsiId: String? = null,

    @Column(name = "business_key")
    var businessKey: String? = null,

    @Column(name = "name")
    var name: String? = null,

    @Column(name = "status")
    var status: String? = null,

    @Column(name = "mission")
    var mission: String? = null,

    @Column(name = "valid_from")
    var validFrom: LocalDateTime? = null,

    @Column(name = "valid_to")
    var validTo: LocalDateTime? = null,

    @Column(name = "active", nullable = false)
    var active: Boolean = true,

    @Column(name = "created_at", nullable = false)
    var createdAt: LocalDateTime = UtcDateTimes.now(),

    @Column(name = "updated_at", nullable = false)
    var updatedAt: LocalDateTime = UtcDateTimes.now()
) {
    /** Создаёт пустой экземпляр сущности, необходимый для JPA. */
    constructor() : this(spacecraftId = "", noradId = 0)
}
