The APIs in the EmployeeController
class have several parameters and return types as described below:
-
Get All Employees
- Endpoint:
/employees/all
- Method: GET
- Parameters: None
- Returns: A
ResponseEntity<Object>
containing a list of allEmployee
objects or an error message in case of failure.
- Endpoint:
-
Search Employee by employeeId
- Endpoint:
/employees/{employeeId}
- Method: GET
- Parameters:
employeeId
(Integer): The ID of the Employee to be viewed.
- Returns: A
ResponseEntity<Object>
containing theEmployee
object with the specifiedemployeeId
or an error message in case of failure.
- Endpoint:
-
Search for all Employees whose age is greater than input age
- Endpoint:
/employees/greaterThanAge/{age}
- Method: GET
- Parameters:
age
(Integer): The age to filter employees by.
- Returns: A
ResponseEntity<Object>
containing a list ofEmployee
objects whose age is greater than the specified age or an error message in case of failure.
- Endpoint:
-
Search for all Employees who are from input city
- Endpoint:
/employees/fromCity/{cityName}
- Method: GET
- Parameters:
cityName
(String): The name of the city to filter employees by.
- Returns: A
ResponseEntity<Object>
containing a list ofEmployee
objects from the specified city or an error message in case of failure.
- Endpoint:
Each of these endpoints is designed to handle specific types of requests related to employees, utilizing path variables (@PathVariable
) for dynamic input values and returning either a list of employees or a single employee wrapped in a ResponseEntity
object for HTTP status and body encapsulation. The ResponseEntity
object allows for flexible HTTP responses, including both the data (in this case, Employee
or a list of Employee
objects) and the HTTP status code, providing a clear indication of the operation's outcome (e.g., HttpStatus.OK
for success or HttpStatus.INTERNAL_SERVER_ERROR
for an error).