Skip to content

Commit

Permalink
optional parameters for find-by-name in employee-db
Browse files Browse the repository at this point in the history
  • Loading branch information
stokpop committed Jun 5, 2021
1 parent 05c3690 commit cb3f264
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ public BurnerMessage checkDatabaseConnection() {
@ApiOperation(value = "Find employees by name.")
@GetMapping("/db/employee/find-by-name")
public List<Employee> findEmployeeByFirstName(
@RequestParam(value = "firstName") String firstName,
@RequestParam(value = "lastName") String lastName) {
@RequestParam(required = false, defaultValue = "") String firstName,
@RequestParam(required = false, defaultValue = "") String lastName) {

if (firstName.length() == 0 && lastName.length() > 0) {
return employeeMapper.selectEmployeeByLastName(lastName);
}
Expand All @@ -71,13 +72,13 @@ else if (firstName.length() > 0) {

@ApiOperation(value = "Find employees by last name.")
@GetMapping("/db/employee/find-by-last-name")
public List<Employee> findEmployeeByLastName(@RequestParam(value = "lastName", defaultValue = "Kolvik") String lastName) {
public List<Employee> findEmployeeByLastName(@RequestParam(defaultValue = "") String lastName) {
return employeeMapper.selectEmployeeByLastName(lastName);
}

@ApiOperation(value = "Execute long query.")
@GetMapping("/db/employee/select-long-time")
public int longQuery(@RequestParam(value = "durationInSec") int durationInSec) {
public int longQuery(@RequestParam int durationInSec) {
return employeeMapper.selectLongTime(durationInSec);
}
}

0 comments on commit cb3f264

Please sign in to comment.