From 121b959134109806fd49aaf95e4eff75cf90096f Mon Sep 17 00:00:00 2001 From: "B.E.N.S.O.N" Date: Mon, 23 Feb 2026 19:10:19 +0800 Subject: [PATCH] Bom Supporting Function --- .../web/BomWeightingScoreController.kt | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/ffii/fpsms/modules/settings/web/BomWeightingScoreController.kt diff --git a/src/main/java/com/ffii/fpsms/modules/settings/web/BomWeightingScoreController.kt b/src/main/java/com/ffii/fpsms/modules/settings/web/BomWeightingScoreController.kt new file mode 100644 index 0000000..35618d3 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/settings/web/BomWeightingScoreController.kt @@ -0,0 +1,42 @@ +package com.ffii.fpsms.modules.settings.web + +import com.ffii.core.exception.NotFoundException +import com.ffii.fpsms.modules.settings.entity.BomWeightingScore +import com.ffii.fpsms.modules.settings.entity.BomWeightingScoreRepository +import jakarta.validation.Valid +import org.springframework.web.bind.annotation.* +import java.math.BigDecimal + +@RestController +@RequestMapping("/bomWeightingScores") +class BomWeightingScoreController( + private val bomWeightingScoreRepository: BomWeightingScoreRepository +) { + @GetMapping + fun getAllBomWeightingScores(): List { + return bomWeightingScoreRepository.findAll().filter { !it.deleted } + } + + @PutMapping("/{id}") + fun updateBomWeightingScore( + @PathVariable id: Long, + @Valid @RequestBody request: UpdateBomWeightingScoreRequest + ): BomWeightingScore { + val entity = bomWeightingScoreRepository.findById(id) + .orElseThrow { NotFoundException() } + + entity.name = request.name + entity.range = request.range + entity.weighting = BigDecimal(request.weighting) + entity.remarks = request.remarks + + return bomWeightingScoreRepository.save(entity) + } +} + +data class UpdateBomWeightingScoreRequest( + val name: String, + val range: Int, + val weighting: Double, + val remarks: String? = null +)