package com.ffii.fpsms.modules.master.web

import com.ffii.fpsms.modules.master.entity.BomRepository
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

data class BomScoreDto(
    val id: Long?,
    val code: String?,
    val name: String?,
    val baseScore: java.math.BigDecimal?,
)

@RestController
@RequestMapping("/bom/scores")
class BomScoreController(
    private val bomRepository: BomRepository,
) {
    @GetMapping
    fun getBomScores(): List<BomScoreDto> {
        return bomRepository.findAllByDeletedIsFalse().map { bom ->
            BomScoreDto(
                id = bom.id,
                code = bom.code,
                name = bom.name,
                baseScore = bom.baseScore,
            )
        }
    }
}
