这是我现在的代码:
@GetMapping
public ResponseEntity<List<EmployeeDTO>> getAllEmployees() {
List<EmployeeDTO> employees = employeeManager.getEmployees();
if(employees.isEmpty()) {
return new ResponseEntity(new CustomError("No employees in database. "), HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(employees, HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.GET, params = {"firstName", "lastName"})
public ResponseEntity<List<EmployeeDTO>> getEmployeesByName(
@ApiParam(name = "firstName", value = "first name")
@RequestParam(value = "firstName", required = false) String firstName,
@ApiParam(name = "lastName", value = "last name")
@RequestParam(value = "lastName", required = false) String lastName) {
List<EmployeeDTO> employees = employeeManager.filterByFirstName(firstName);
if(employees.isEmpty()) {
return new ResponseEntity(new CustomError("No employees with given first name found. "), HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(employees, HttpStatus.OK);
}
我想要实现的目标: 带有UI的swagger可选的名字和姓氏字段。 目前它们要么在UI中消失,要么都是必需的。它可行吗?