location controller
This commit is contained in:
36
src/main/java/fr/eni/demo/controller/LocationController.java
Normal file
36
src/main/java/fr/eni/demo/controller/LocationController.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package fr.eni.demo.controller;
|
||||||
|
|
||||||
|
import fr.eni.demo.bll.ClientService;
|
||||||
|
import fr.eni.demo.bll.LocationService;
|
||||||
|
import fr.eni.demo.bo.Client;
|
||||||
|
import fr.eni.demo.bo.Location;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/location")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LocationController {
|
||||||
|
|
||||||
|
private final LocationService locationService;
|
||||||
|
|
||||||
|
// Ajouter une location
|
||||||
|
@PostMapping
|
||||||
|
public ResponseEntity<Map<String, Object>> create(@RequestBody Location location) {
|
||||||
|
locationService.add(location);
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("message", "Location added");
|
||||||
|
response.put("status", true);
|
||||||
|
response.put("data", new HashMap<>());
|
||||||
|
|
||||||
|
return ResponseEntity.ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user