package com.ffii.fpsms.modules.pickOrder.web.models

import com.ffii.fpsms.modules.pickOrder.entity.Truck
import java.time.LocalTime

/**
 * 僅供 `findAllUniqueTruckLanceCodeAndRemarkCombinations` 回傳，避免序列化 JPA
 * 關聯（shop / logistic）產生超大或非法 JSON。
 */
data class TruckLaneCombinationResponse(
    val id: Long,
    val truckLanceCode: String?,
    val departureTime: LocalTime?,
    val loadingSequence: Int?,
    val districtReference: String?,
    val storeId: String?,
    val remark: String?,
    val shopName: String?,
    val shopCode: String?,
)

fun Truck.toLaneCombinationResponse(): TruckLaneCombinationResponse {
    return TruckLaneCombinationResponse(
        id = this.id ?: 0L,
        truckLanceCode = this.truckLanceCode,
        departureTime = this.departureTime,
        loadingSequence = this.loadingSequence,
        districtReference = this.districtReference,
        storeId = this.storeId,
        remark = this.remark,
        shopName = this.shopName,
        shopCode = this.shopCode,
    )
}
