Преглед на файлове

Bom Supporting Function

master
B.E.N.S.O.N преди 4 дни
родител
ревизия
121b959134
променени са 1 файла, в които са добавени 42 реда и са изтрити 0 реда
  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 Целия файл

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

Зареждане…
Отказ
Запис