API 1.0.41 customer_training_plan details, exercises

This commit is contained in:
Bossanyi Tibor
2021-05-20 15:02:48 +02:00
parent aeb62acaa3
commit d02f6bd1f7
16 changed files with 203 additions and 17 deletions
@@ -19,7 +19,7 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
private val customerPropertyRepository: CustomerPropertyRepository,
private val exerciseResultRepository: ExerciseResultRepository,
private val customerActivityRepository: CustomerActivityRepository,
private val customerTrainingPlanRepository: CustomerTrainingPlanRepository
private val customerTrainingPlanRepository: CustomerTrainingPlanRepository,
) {
@GetMapping("/app_customer_package/{id}")
@@ -1,8 +1,7 @@
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.model.CustomerTrainingPlanExercise
import com.aitrainer.api.repository.CustomerTrainingPlanRepository
import org.slf4j.LoggerFactory
import org.springframework.http.ResponseEntity
@@ -17,7 +16,7 @@ class CustomerTrainingPlanController(private val customerTrainingPlanRepository:
@PostMapping("/customer_training_plan")
fun createNewCustomerTrainingPlan(@Valid @RequestBody customerTrainingPlan: CustomerTrainingPlan): ResponseEntity<CustomerTrainingPlan> {
logger.info("Create customer property: $customerTrainingPlan")
logger.info("Create customer training plan: $customerTrainingPlan")
return ResponseEntity.ok().body(customerTrainingPlanRepository.save(customerTrainingPlan))
}
@@ -0,0 +1,31 @@
package com.aitrainer.api.controller
import com.aitrainer.api.model.CustomerTrainingPlanExercise
import com.aitrainer.api.repository.CustomerTrainingPlanExerciseRepository
import org.slf4j.LoggerFactory
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import javax.validation.Valid
@RestController
@RequestMapping("/api")
class CustomerTrainingPlanExerciseController(private val customerTrainingPlanExerciseRepository: CustomerTrainingPlanExerciseRepository) {
private val logger = LoggerFactory.getLogger(javaClass)
@PostMapping("/customer_training_plan_exercise")
fun createNewCustomerTrainingPlanExercise(@Valid @RequestBody customerTrainingPlanExercise: CustomerTrainingPlanExercise): ResponseEntity<CustomerTrainingPlanExercise> {
logger.info("Create customer property: $customerTrainingPlanExercise")
return ResponseEntity.ok().body(customerTrainingPlanExerciseRepository.save(customerTrainingPlanExercise))
}
@GetMapping("/customer_training_plan_exercise/{id}")
fun getAllByCustomerId(@PathVariable(value = "id") customerId: Long): ResponseEntity<List<CustomerTrainingPlanExercise>> {
val exerciseList: List<CustomerTrainingPlanExercise> = customerTrainingPlanExerciseRepository.findAllByCustomerId(customerId)
logger.info("Get all training plan exercise list by customerId")
return if(exerciseList.isNotEmpty())
ResponseEntity.ok().body(exerciseList) else
ResponseEntity.notFound().build()
}
}