package space.nstart.pcp.pcp_request_service.entity

import space.nstart.pcp.pcp_request_service.utils.UtcDateTimes
import ballistics.types.FleghtLineSector
import ballistics.utils.toDateTime
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.Table
import java.time.LocalDateTime

@Entity
@Table(name = "earth_coverage")
class EarthCoverageEntity(
    @Id
    @Column(name = "earth_coverage_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    val id : Long? = null,
    @Column(nullable = false)
    val satelliteId : Long = 0,
    @Column(nullable = false)
    val cellNumber : Long = 0,
    @Column(nullable = false)
    val tStart : LocalDateTime = UtcDateTimes.now(),
    @Column(nullable = false)
    val tStop  : LocalDateTime = UtcDateTimes.now(),
    ) {
    constructor(fl : FleghtLineSector, sector : Int, sat : Long) : this(
        null,
        sat,
        sector.toLong(),
        toDateTime(fl.tStart),
        toDateTime(fl.tStop)
    )
}
