package space.nstart.pcp.pcp_satellite_catalog_service.entity

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import space.nstart.pcp.pcp_types_lib.dto.satellite.SatelliteSummaryDTO
import space.nstart.pcp.pcp_types_lib.dto.satellite.SatelliteVisualizationDTO

@Entity
@Table(name = "satellite")
class SatelliteEntity(
    @Id
    val id: Long = 0,
    @Column(name = "norad_id")
    val noradId: Long? = null,
    @Column(nullable = false)
    val code: String = "",
    @Column(nullable = false)
    val name: String = "",
    @Column(name = "type_code", nullable = false)
    val typeCode: String = "",
    @Column(nullable = false)
    val active: Boolean = true,
    @Column(name = "scan_tle", nullable = false)
    val scanTle: Boolean = false,
    @Column(nullable = false)
    val red: Short = 255,
    @Column(nullable = false)
    val green: Short = 0,
    @Column(nullable = false)
    val blue: Short = 0
) {
    fun toSummaryDTO() = SatelliteSummaryDTO(
        id = id,
        noradId = noradId,
        code = code,
        name = name,
        typeCode = typeCode,
        active = active,
        scanTle = scanTle,
        visualization = SatelliteVisualizationDTO(
            red = red,
            green = green,
            blue = blue
        )
    )
}
