API 1.0.25 update CustomerProperty

This commit is contained in:
Bossanyi Tibor
2021-02-15 18:04:22 +01:00
parent bd0a078640
commit 59d09ed115
9 changed files with 69 additions and 13 deletions
@@ -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>> {
@@ -17,6 +17,6 @@ logging.config=classpath:logback-spring.xml
logging.file=logs
# if the database structure has been changed, increment this version number
application.version=1.0.24
application.version=1.0.25
jwt.secret=aitrainer
+1 -1
View File
@@ -17,6 +17,6 @@ logging.config=classpath:logback-spring.xml
logging.file=logs
# if the database structure has been changed, increment this version number
application.version=1.0.24
application.version=1.0.25
jwt.secret=aitrainer