merge stock service

This commit is contained in:
Olivier PARPAILLON
2025-07-16 12:04:58 +02:00
12 changed files with 186 additions and 139 deletions

View File

@@ -19,6 +19,7 @@ public class StockController {
private final StockService stockService;
<<<<<<< HEAD
// Ajouter un stock
@PostMapping
public ResponseEntity<Map<String, Object>> create(@RequestBody Stock stock) {
@@ -54,4 +55,28 @@ public class StockController {
response.put("data", result);
return ResponseEntity.ok(response);
}
=======
// Ajouter un stock
@PostMapping
public ResponseEntity<Map<String, Object>> create(@RequestBody Stock stock) {
stockService.add(stock);
return buildResponse("Stock added", true, new HashMap<>());
}
// Chercher un stock par id
@GetMapping("/{id}")
public ResponseEntity<Map<String, Object>> findById(@PathVariable Long id) {
Optional<Stock> result = stockService.findById(id);
return buildResponse("Stock found", true, result);
}
// Reponse formatée
private ResponseEntity<Map<String, Object>> buildResponse(String message, boolean status, Object data) {
Map<String, Object> response = new HashMap<>();
response.put("message", message);
response.put("status", status);
response.put("data", data);
return ResponseEntity.ok(response);
}
>>>>>>> c09dfc497575d616cee9f47afcc62667dbb08b0c
}