Delete
Service
public void delete(UUID id) {
if (!departmentRepository.existsById(id)) {
throw new ResourceNotFoundException("Department not found");
}
departmentRepository.deleteById(id);
}
Controller
@DeleteMapping(value = "/{id}")
public ResponseEntity<DepartmentDTO> delete(@PathVariable UUID id) {
departmentService.delete(id);
return ResponseEntity.noContent().build();
}
Atualizado