Merge branch 'main' of https://github.com/Parpaillax/Ludotheque
This commit is contained in:
@@ -11,4 +11,5 @@ public interface ClientService {
|
|||||||
List<Client> findByName(String name);
|
List<Client> findByName(String name);
|
||||||
void fullUpdate(Long id, Client client, Adresse adresseDetails);
|
void fullUpdate(Long id, Client client, Adresse adresseDetails);
|
||||||
void updateLocation(Long idClient, Adresse adresseDetails);
|
void updateLocation(Long idClient, Adresse adresseDetails);
|
||||||
|
void delete(Long idClient);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public class ClientServiceImpl implements ClientService {
|
|||||||
return clients;
|
return clients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void fullUpdate(Long id, Client clientDetails, Adresse adresseDetails) {
|
public void fullUpdate(Long id, Client clientDetails, Adresse adresseDetails) {
|
||||||
Client client = clientRepository.findById(id)
|
Client client = clientRepository.findById(id)
|
||||||
.orElseThrow(() -> new EntityNotFoundException("Client non trouvé avec l'id " + id));
|
.orElseThrow(() -> new EntityNotFoundException("Client non trouvé avec l'id " + id));
|
||||||
@@ -82,6 +83,7 @@ public class ClientServiceImpl implements ClientService {
|
|||||||
clientRepository.save(client);
|
clientRepository.save(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void updateLocation(Long idClient, Adresse adresseDetails) {
|
public void updateLocation(Long idClient, Adresse adresseDetails) {
|
||||||
Client client = clientRepository.findById(idClient)
|
Client client = clientRepository.findById(idClient)
|
||||||
.orElseThrow(() -> new EntityNotFoundException("Client non trouvé avec l'id " + idClient));
|
.orElseThrow(() -> new EntityNotFoundException("Client non trouvé avec l'id " + idClient));
|
||||||
@@ -89,4 +91,12 @@ public class ClientServiceImpl implements ClientService {
|
|||||||
client.setAdresse(adresseDetails);
|
client.setAdresse(adresseDetails);
|
||||||
clientRepository.save(client);
|
clientRepository.save(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Long idClient) {
|
||||||
|
Client client = clientRepository.findById(idClient)
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException("Client non trouvé avec l'id " + idClient));
|
||||||
|
|
||||||
|
clientRepository.delete(client);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,4 +78,14 @@ public class ClientController {
|
|||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/{id]")
|
||||||
|
public ResponseEntity<Map<String, Object>> delete(@PathVariable Long id) {
|
||||||
|
clientService.delete(id);
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("message", "Client deleted successfully");
|
||||||
|
response.put("status", 200);
|
||||||
|
response.put("data", new HashMap<>());
|
||||||
|
return ResponseEntity.ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user