From 31ec70f02e5f46174536ed4797f10e78061587be Mon Sep 17 00:00:00 2001 From: HarmandI Date: Tue, 15 Feb 2022 15:39:35 +0100 Subject: [PATCH] addTache --- .../java/fr/organizee/controller/TacheController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/organizee/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java index 681d760..82ce274 100644 --- a/src/main/java/fr/organizee/controller/TacheController.java +++ b/src/main/java/fr/organizee/controller/TacheController.java @@ -1,6 +1,7 @@ package fr.organizee.controller; import fr.organizee.model.Tache; +import fr.organizee.model.TodoList; import fr.organizee.repository.TacheRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -61,10 +62,13 @@ public class TacheController { } // Ajoute une tache - @PostMapping(value="/add", produces="application/json", consumes="application/json") - public ResponseEntity addTache(@RequestBody Tache tache){ + @PostMapping(value="/add/{idTodoList}", produces="application/json", consumes="application/json") + public ResponseEntity addTache(@RequestBody Tache tache,@PathVariable Integer idTodoList){ Tache resultTache = null; try { + TodoList todolist=new TodoList(); + todolist.setId(idTodoList); + tache.setTodolist(todolist); resultTache = tacheRepo.saveAndFlush(tache); } catch (Exception e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());