From c0f86d1c3f98575f174348f128e685dce68aaeb2 Mon Sep 17 00:00:00 2001 From: Olivier PARPAILLON Date: Wed, 16 Jul 2025 12:08:36 +0200 Subject: [PATCH] fix merge conflict --- .../eni/demo/controller/StockController.java | 49 ++++--------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/src/main/java/fr/eni/demo/controller/StockController.java b/src/main/java/fr/eni/demo/controller/StockController.java index 040a8e5..43487e8 100644 --- a/src/main/java/fr/eni/demo/controller/StockController.java +++ b/src/main/java/fr/eni/demo/controller/StockController.java @@ -19,29 +19,18 @@ public class StockController { private final StockService stockService; -<<<<<<< HEAD // Ajouter un stock @PostMapping public ResponseEntity> create(@RequestBody Stock stock) { stockService.add(stock); - Map response = new HashMap<>(); - response.put("message", "Stock added"); - response.put("status", true); - response.put("data", new HashMap<>()); - - return ResponseEntity.ok(response); + return buildResponse("Stock added", true, new HashMap<>()); } // Chercher des stocks par id @GetMapping("/{id}") public ResponseEntity> findById(@PathVariable Long id) { Optional result = stockService.findById(id); - Map response = new HashMap<>(); - response.put("message", "List of Clients found"); - response.put("status", 200); - response.put("data", result); - - return ResponseEntity.ok(response); + return buildResponse("Stock added", true, result); } // Trouver les jeux par nom et compter le result par nom @@ -49,34 +38,14 @@ public class StockController { @GetMapping("/{name}") public ResponseEntity> findByName(@PathVariable String name) { List result = stockService.findAllByName(name); + return buildResponse("Stock added", true, result); + } + + private ResponseEntity> buildResponse(String message, boolean status, Object data) { Map response = new HashMap<>(); - response.put("message", "List of Clients found"); - response.put("status", 200); - response.put("data", result); + response.put("message", message); + response.put("status", status); + response.put("data", data); return ResponseEntity.ok(response); } -======= - // Ajouter un stock - @PostMapping - public ResponseEntity> create(@RequestBody Stock stock) { - stockService.add(stock); - return buildResponse("Stock added", true, new HashMap<>()); - } - - // Chercher un stock par id - @GetMapping("/{id}") - public ResponseEntity> findById(@PathVariable Long id) { - Optional result = stockService.findById(id); - return buildResponse("Stock found", true, result); - } - - // Reponse formatée - private ResponseEntity> buildResponse(String message, boolean status, Object data) { - Map response = new HashMap<>(); - response.put("message", message); - response.put("status", status); - response.put("data", data); - return ResponseEntity.ok(response); - } ->>>>>>> c09dfc497575d616cee9f47afcc62667dbb08b0c }