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

import com.ffii.fpsms.modules.master.service.BomScoreRecalculateService
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

data class BomScoreRecalcResponse(
    val updatedCount: Int,
)

@RestController
@RequestMapping("/bom/scores")
class BomScoreRecalcController(
    private val bomScoreRecalculateService: BomScoreRecalculateService,
) {

    /**
     * Recalculate and persist baseScore for all BOMs using the current weighting configuration.
     */
    @PostMapping("/recalculate")
    fun recalculateAll(): BomScoreRecalcResponse {
        val count = bomScoreRecalculateService.recalculateAllBaseScores()
        return BomScoreRecalcResponse(updatedCount = count)
    }
}

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

import com.ffii.fpsms.modules.master.service.BomScoreRecalculateService
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

data class BomScoreRecalcResponse(
    val updatedCount: Int,
)

@RestController
@RequestMapping("/bom/scores")
class BomScoreRecalcController(
    private val bomScoreRecalculateService: BomScoreRecalculateService,
) {

    /**
     * Recalculate and persist baseScore for all BOMs using the current weighting configuration.
     */
    @PostMapping("/recalculate")
    fun recalculateAll(): BomScoreRecalcResponse {
        val count = bomScoreRecalculateService.recalculateAllBaseScores()
        return BomScoreRecalcResponse(updatedCount = count)
    }
}

