package space.nstart.pcp.complan.db.entity

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.FetchType
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import java.time.LocalDateTime
import java.util.UUID
import space.nstart.pcp.pcp_types_lib.utils.UtcDateTimes

@Table(name = "dynamic_plan_route")
@Entity
class DynamicPlanRouteEntity(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    var id: Long? = null,

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "run_id", nullable = false)
    var run: DynamicPlanRunEntity? = null,

    @Column(name = "request_id", nullable = false)
    var requestId: UUID? = null,

    @Column(name = "satellite_id", nullable = false)
    var satelliteId: Long = 0,

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

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

    @Column(name = "duration", nullable = false)
    var duration: Double = 0.0,

    @Column(name = "revolution", nullable = false)
    var revolution: Long = 0,

    @Column(name = "roll", nullable = false)
    var roll: Double = 0.0,

    @Column(name = "contour_wkt", nullable = false, columnDefinition = "TEXT")
    var contourWkt: String = "",

    @Column(name = "route_order", nullable = false)
    var routeOrder: Int = 0
) {
    constructor() : this(id = null)
}
