API 1.0.37+2 SSL, password encryption, TrainingPlanTranslation
This commit is contained in:
@@ -18,7 +18,9 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
private val purchaseRepository: PurchaseRepository,
|
||||
private val customerPropertyRepository: CustomerPropertyRepository,
|
||||
private val exerciseResultRepository: ExerciseResultRepository,
|
||||
private val customerActivityRepository: CustomerActivityRepository) {
|
||||
private val customerActivityRepository: CustomerActivityRepository,
|
||||
private val customerTrainingPlanRepository: CustomerTrainingPlanRepository
|
||||
) {
|
||||
|
||||
@GetMapping("/app_customer_package/{id}")
|
||||
fun getCustomerPackageData(@PathVariable(value = "id") customerId: Long): ResponseEntity<String> {
|
||||
@@ -60,6 +62,9 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
val listActivityResult = customerActivityRepository.findByCustomerId(customerId)
|
||||
val listActivityJson = gson.toJson(listActivityResult)
|
||||
|
||||
val listTrainingPlan = customerTrainingPlanRepository.findAllByCustomerId(customerId)
|
||||
val listTrainingPlanJson = gson.toJson(listTrainingPlan)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(Customer::class.simpleName, customerJson) +
|
||||
"|||" + getClassRecord(CustomerExerciseDevice::class.simpleName, listCustomerExerciseDeviceJson) +
|
||||
@@ -69,7 +74,8 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
"|||" + getClassRecord(CustomerProperty::class.simpleName+"All", listCustomerPropertyAllJson) +
|
||||
"|||" + getClassRecord(CustomerProperty::class.simpleName, listCustomerPropertyJson) +
|
||||
"|||" + getClassRecord(ExerciseResult::class.simpleName, listExerciseResultJson+
|
||||
"|||" + getClassRecord(CustomerActivity::class.simpleName, listActivityJson))
|
||||
"|||" + getClassRecord(CustomerActivity::class.simpleName, listActivityJson) +
|
||||
"|||" + getClassRecord(CustomerTrainingPlan::class.simpleName, listTrainingPlanJson))
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.CustomerProperty
|
||||
import com.aitrainer.api.model.CustomerTrainingPlan
|
||||
import com.aitrainer.api.repository.CustomerPropertyRepository
|
||||
import com.aitrainer.api.repository.CustomerTrainingPlanRepository
|
||||
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
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
class CustomerTrainingPlanController(private val customerTrainingPlanRepository: CustomerTrainingPlanRepository) {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@PostMapping("/customer_training_plan")
|
||||
fun createNewCustomerTrainingPlan(@Valid @RequestBody customerTrainingPlan: CustomerTrainingPlan): ResponseEntity<CustomerTrainingPlan> {
|
||||
logger.info("Create customer property: $customerTrainingPlan")
|
||||
return ResponseEntity.ok().body(customerTrainingPlanRepository.save(customerTrainingPlan))
|
||||
}
|
||||
|
||||
@Secured
|
||||
@PostMapping("customer_training_plan/update/{id}")
|
||||
fun updateCustomerProperty(@PathVariable(value = "id") trainingPlanId: Long,
|
||||
@Valid @RequestBody customerTrainingPlanToUpdate: CustomerTrainingPlan): ResponseEntity<CustomerTrainingPlan> {
|
||||
val customerTrainingPlan = customerTrainingPlanRepository.findById(trainingPlanId).orElse(null)
|
||||
?: return ResponseEntity.notFound().build()
|
||||
|
||||
val updatedCustomerTrainingPlan = customerTrainingPlan.copy(
|
||||
trainingPlanId = customerTrainingPlanToUpdate.trainingPlanId,
|
||||
customerId = customerTrainingPlanToUpdate.customerId,
|
||||
dateAdd = customerTrainingPlanToUpdate.dateAdd
|
||||
)
|
||||
return ResponseEntity.ok().body(customerTrainingPlanRepository.save(updatedCustomerTrainingPlan))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user