From 31ec70f02e5f46174536ed4797f10e78061587be Mon Sep 17 00:00:00 2001 From: HarmandI Date: Tue, 15 Feb 2022 15:39:35 +0100 Subject: [PATCH 1/2] 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()); From eb7b7777ec8b3a755b31784f947825923a4f8589 Mon Sep 17 00:00:00 2001 From: HarmandI Date: Thu, 17 Feb 2022 11:38:46 +0100 Subject: [PATCH 2/2] update tache --- src/main/java/fr/organizee/controller/TacheController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/organizee/controller/TacheController.java b/src/main/java/fr/organizee/controller/TacheController.java index 82ce274..58e5ccc 100644 --- a/src/main/java/fr/organizee/controller/TacheController.java +++ b/src/main/java/fr/organizee/controller/TacheController.java @@ -77,11 +77,14 @@ public class TacheController { return ResponseEntity.status(HttpStatus.CREATED).body(resultTache); } - //Met a jour les informations d'une date avec son ID + //Met a jour les informations d'une tache avec son ID @PutMapping("/update/{id}") public ResponseEntity updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception { Tache resultTache = null; try { + TodoList todolist=new TodoList(); + todolist.setId(tacheRepo.findById(tache.getId()).get().getTodolist().getId()); + tache.setTodolist(todolist); resultTache = tacheRepo.save(tache); } catch (Exception e) {