exercise_plan_detail_id in exercises

This commit is contained in:
Bossanyi Tibor
2020-09-14 23:32:13 +02:00
parent efe7dea584
commit 3f8eb6ef00
11 changed files with 27 additions and 45 deletions
@@ -54,11 +54,10 @@ class ExercisePlanController( private val exercisePlanRepository: ExercisePlanRe
@Secured
@PostMapping("/exercise_plan/delete/{exercisePlanId}")
fun deleteExercisePlanById(@PathVariable(value = "exercisePlanId") exercisePlanId: Int,
@Valid @RequestBody exercisePlan: ExercisePlan)
fun deleteExercisePlanById(@PathVariable(value = "exercisePlanId") exercisePlanId: Int)
:ResponseEntity<HttpStatus> {
val returnPlan = exercisePlanRepository.findById(exercisePlanId).orElse(null)
?: return ResponseEntity.ok().body(HttpStatus.NOT_FOUND)
?: return ResponseEntity.notFound().build()
try {
exercisePlanRepository.delete(returnPlan)
} catch (e: IllegalArgumentException ) {
@@ -22,15 +22,6 @@ class ExercisePlanDetailController( private val exercisePlanDetailRepository: Ex
return ResponseEntity.ok().body(exercisePlanDetailRepository.save(exercisePlanDetail))
}
/* @GetMapping("/exercise_plan_detail/last/{customerId}")
fun getExercisePlanByCustomerId(@PathVariable(value = "customerId") customerId: Long): ResponseEntity<List<ExercisePlanDetail>> {
val list: List<ExercisePlanDetail> = exercisePlanDetailRepository.getLastExercisePlanDetail(customerId)
logger.info("-- getExercisePlanByCustomerId id: $customerId -- $list")
return ResponseEntity.ok().body(list)
}
*/
@GetMapping("/exercise_plan_detail/{exercisePlanId}")
fun getExercisePlanByExercisePlanId(@PathVariable(value = "exercisePlanId") exercisePlanId: Int): ResponseEntity<List<ExercisePlanDetail>> {
val list: List<ExercisePlanDetail> = exercisePlanDetailRepository.findByExercisePlanId(exercisePlanId)
@@ -61,11 +52,10 @@ class ExercisePlanDetailController( private val exercisePlanDetailRepository: Ex
@Secured
@PostMapping("/exercise_plan_detail/delete/{exercisePlanDetailId}")
fun deleteExercisePlanDetailById(@PathVariable(value = "exercisePlanDetailId") exercisePlanDetailId: Long,
@Valid @RequestBody exercisePlanDetail: ExercisePlanDetail)
fun deleteExercisePlanDetailById(@PathVariable(value = "exercisePlanDetailId") exercisePlanDetailId: Long)
:ResponseEntity<HttpStatus> {
val returnPlanDetail = exercisePlanDetailRepository.findById(exercisePlanDetailId).orElse(null)
?: return ResponseEntity.ok().body(HttpStatus.NOT_FOUND)
?: return ResponseEntity.notFound().build()
try {
exercisePlanDetailRepository.delete(returnPlanDetail)
} catch (e: IllegalArgumentException ) {