API 1.0.25 update CustomerProperty
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.CustomerProperty
|
||||
import com.aitrainer.api.model.ExercisePlanDetail
|
||||
import com.aitrainer.api.model.Purchase
|
||||
import com.aitrainer.api.repository.CustomerPropertyRepository
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.security.access.annotation.Secured
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import javax.validation.Valid
|
||||
|
||||
@@ -20,6 +19,20 @@ class CustomerPropertyController(private val customerPropertyRepository: Custome
|
||||
return ResponseEntity.ok().body(customerPropertyRepository.save(customerProperty))
|
||||
}
|
||||
|
||||
@Secured
|
||||
@PostMapping("customer_property/update/{id}")
|
||||
fun updateCustomerProperty(@PathVariable(value = "id") propertyId: Long,
|
||||
@Valid @RequestBody propertyToUpdate: CustomerProperty): ResponseEntity<CustomerProperty> {
|
||||
val customerProperty = customerPropertyRepository.findById(propertyId).orElse(null)
|
||||
?: return ResponseEntity.notFound().build()
|
||||
|
||||
val updatedCustomerProperty = customerProperty.copy(
|
||||
propertyValue = propertyToUpdate.propertyValue,
|
||||
dateAdd = propertyToUpdate.dateAdd
|
||||
)
|
||||
return ResponseEntity.ok().body(customerPropertyRepository.save(updatedCustomerProperty))
|
||||
}
|
||||
|
||||
@GetMapping("/customer_property/{id}")
|
||||
fun getAllByCustomerId(@PathVariable(value = "id") customerId: Long): ResponseEntity<List<CustomerProperty>> {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user