Given four files EmployeeController.java
, EmployeeRepository.java
, EmployeeService.java
and Employee.java
.
The EmployeeService
class has a variable named employeeList
, which is a HashMap that holds Integer
s as keys and Employee
objects as values. Initially, it contains data of 6 employees.
-
Employee.java
:Employee
class should contain the following attributes.Attribute Type employeeId int employeeName String email String department String -
EmployeeRepository.java
: Create aninterface
containing required methods. -
EmployeeService.java
: Update the service class with logic for managing employee data. -
EmployeeController.java
: Create the controller class to handle HTTP requests.
Implement the following APIs.
Returns a list of all employees
in the employeeList
.
[
{
"employeeId": 1,
"employeeName": "John Doe",
"email": "johndoe@example.com",
"department": "Marketing"
},
...
]
Creates a new employee in the employeeList
. The employeeId
is auto-incremented.
{
"employeeName": "Henry Nicholas",
"email": "henrynicholas@example.com",
"department": "IT"
}
{
"employeeId": 7,
"employeeName": "Henry Nicholas",
"email": "henrynicholas@example.com",
"department": "IT"
}
Returns a employee based on the employeeId
. If the given employeeId
is not found in the employeeList
, raise ResponseStatusException
with HttpStatus.NOT_FOUND
.
{
"employeeId": 2,
"employeeName": "Jane Smith",
"email": "janesmith@example.com",
"department": "Human Resources"
}
Updates the details of a employee in the employeeList
based on the employeeId
. If the given employeeId
is not found in the employeeList
, raise ResponseStatusException
with HttpStatus.NOT_FOUND
.
{
"employeeName": "Steve Smith",
"email": "stevesmith@example.com"
}
{
"employeeId": 2,
"employeeName": "Steve Smith",
"email": "stevesmith@example.com",
"department": "Human Resources"
}
Deletes a employee from the employeeList
based on the employeeId
. If the given employeeId
is not found in the employeeList
, raise ResponseStatusException
with HttpStatus.NOT_FOUND
.
Do not modify the code in EmployeeApplication.java