API 1.0.16 CustomerExerciseDevice.delete fix

This commit is contained in:
bossanyit
2020-11-28 12:01:52 +01:00
parent d37629ff72
commit 5e75fce2bc
8 changed files with 815 additions and 412 deletions
@@ -33,10 +33,12 @@ class CustomerExerciseDeviceController(private val customerExerciseDeviceReposit
}
@Secured
@PostMapping("/customer_exercise_device/delete/")
fun deleteCustomerExerciseDevice(@Valid @RequestBody customerExerciseDevice: CustomerExerciseDevice) :ResponseEntity<HttpStatus> {
val returnDevice = customerExerciseDeviceRepository.findById(customerExerciseDevice.customerExerciseDeviceId).orElse(null)
?: return ResponseEntity.notFound().build()
@PostMapping("/customer_exercise_device/delete/{id}")
fun deleteCustomerExerciseDevice(@PathVariable(value = "id") customerExerciseDeviceId: Long) :ResponseEntity<HttpStatus> {
logger.info("Delete device by ID: $customerExerciseDeviceId")
val returnDevice = customerExerciseDeviceRepository.findById(customerExerciseDeviceId).orElse(null)
?: return ResponseEntity.notFound().build()
try {
customerExerciseDeviceRepository.delete(returnDevice)
} catch (e: IllegalArgumentException ) {
@@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull
data class CustomerExerciseDevice (
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
val customerExerciseDeviceId: Long = 0,
var customerExerciseDeviceId: Long = 0,
@get: NotNull var exerciseDeviceId: Long?,
@get: NotNull var customerId: Long?,
@get: NotNull var favourite: Boolean?,