Browse Source

Bom Supporting Function

master
B.E.N.S.O.N 4 days ago
parent
commit
121b959134
1 changed files with 42 additions and 0 deletions
  1. +42
    -0
      src/main/java/com/ffii/fpsms/modules/settings/web/BomWeightingScoreController.kt

+ 42
- 0
src/main/java/com/ffii/fpsms/modules/settings/web/BomWeightingScoreController.kt View File

@@ -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<BomWeightingScore> {
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
)

Loading…
Cancel
Save