Skip to content

Commit 2ca0752

Browse files
committed
1 parent 99f734b commit 2ca0752

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/main/java/guru/springframework/spring6restmvc/controller/CustomerController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ public class CustomerController {
2121

2222
private final CustomerService customerService;
2323

24+
@DeleteMapping("{customerId}")
25+
public ResponseEntity deleteCustomer(@PathVariable("customerId") UUID customerId) {
26+
customerService.deleteCustomerById(customerId);
27+
28+
return new ResponseEntity(HttpStatus.NO_CONTENT);
29+
}
30+
2431
@PutMapping("{customerId}")
2532
public ResponseEntity updateById(@PathVariable("customerId") UUID customerId, @RequestBody Customer customer) {
2633
customerService.updateCustomerById(customerId, customer);

src/main/java/guru/springframework/spring6restmvc/service/CustomerService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ public interface CustomerService {
1111
Customer saveNewCustomer(Customer customer);
1212

1313
void updateCustomerById(UUID customerId, Customer customer);
14+
15+
void deleteCustomerById(UUID customerId);
1416
}

src/main/java/guru/springframework/spring6restmvc/service/CustomerServiceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,9 @@ public void updateCustomerById(UUID customerId, Customer customer) {
7676

7777
customerMap.put(existingCustomer.getId(), existingCustomer);
7878
}
79+
80+
@Override
81+
public void deleteCustomerById(UUID customerId) {
82+
customerMap.remove(customerId);
83+
}
7984
}

0 commit comments

Comments
 (0)