третья попытка((((

This commit is contained in:
2025-11-29 20:11:44 +03:00
parent 0fc0678392
commit c4afce7fa6
5 changed files with 19 additions and 47 deletions

View File

@@ -21,7 +21,10 @@ public class EmployeeController {
@GetMapping("/{code}")
public ResponseEntity<Employee> getEmployeeByCode(@PathVariable String code) {
Optional<Employee> employeeOpt = employeeService.findByCode(code);
return employeeOpt.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build());
if (employeeOpt.isPresent()) {
return ResponseEntity.ok(employeeOpt.get());
} else {
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
}
}
}