Merge branch 'main' of https://github.com/Parpaillax/Ludotheque
This commit is contained in:
55
src/main/java/fr/eni/demo/controller/AddressController.java
Normal file
55
src/main/java/fr/eni/demo/controller/AddressController.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package fr.eni.demo.controller;
|
||||
|
||||
import fr.eni.demo.bll.AdresseService;
|
||||
import fr.eni.demo.bll.StockService;
|
||||
import fr.eni.demo.bo.Adresse;
|
||||
import fr.eni.demo.bo.Stock;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/address")
|
||||
@RequiredArgsConstructor
|
||||
public class AddressController {
|
||||
|
||||
private final AdresseService adresseService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Map<String, Object>> create(@RequestBody Adresse adresse) {
|
||||
adresseService.add(adresse);
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("message", "Adresse added");
|
||||
response.put("status", true);
|
||||
response.put("data", new HashMap<>());
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Map<String, Object>> findById(@PathVariable Long id) {
|
||||
Adresse result = adresseService.findById(id);
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("message", "Adresse find");
|
||||
response.put("status", true);
|
||||
response.put("data", result);
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@GetMapping("/client/{id}")
|
||||
public ResponseEntity<Map<String, Object>> findByIdClient(@PathVariable Long id) {
|
||||
Adresse result = adresseService.findAdresseByClientId(id);
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("message", "Adresse find");
|
||||
response.put("status", true);
|
||||
response.put("data", result);
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user