From the earlier post mentioned here it is clear that Controller layer is responsible for returning Http response. However code example mentioned there still needs some logic to return which type of Http response. If in the service layer - employeeService.findEmployeeById(id) returns null then the controller needs a logic to decide what type of Http status to be returned.
There could be many if-else condition based on status of emp. How best to avoid logic in Controller
@GetMapping("/{id}")
public ResponseEntity<Employee> getEmployee(@PathVariable Long id) {
Employee emp = employeeService.findEmployeeById(id);
if(emp != null)
return ResponseEntity.status(HttpStatus.OK).body(emp);
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}