-
Notifications
You must be signed in to change notification settings - Fork 240
10. Build Get All Employees REST API
Ramesh Fadatare edited this page Sep 11, 2022
·
1 revision
List<EmployeeDto> getAllEmployees();
@Override
public List<EmployeeDto> getAllEmployees() {
List<Employee> employees = employeeRepository.findAll();
return employees.stream()
.map(employee -> EmployeeConverter.mapToEmployeeDto(employee))
.collect(Collectors.toList());
}
// build get all employees REST API
@GetMapping
public ResponseEntity<List<EmployeeDto>> getAllEmployees(){
List<EmployeeDto> employees = employeeService.getAllEmployees();
return new ResponseEntity<>(employees, HttpStatus.OK);
}