The purpose of this application is to show how to use Maven, Spring, and Tomcat together to produce a functioning Rest API Backend system. This system does NOT make use of a database, in favor of storing all of its data in an ArrayList. The application initializes this ArrayList and provides a few endpoints to read the data from that list.
The ArrayList contains Employee objects.
Fields of the employee objects include
- Employee id
- Employee first name
- Employee last name
- Employee Salary
- A flag saying whether or not the employee has a 401K Plan
- Id number of the employee's company
- Id number of the employee's health plan
No relationships exist between employee and other objects.
This application works with employee data that is stored inside an ArrayList.
Using the provided seed data, the given endpoint will produce the stated output. Expand each endpoint to see its correct output.
http://localhost:2019/data/allemployees
[
{
"id": 3,
"fname": "John",
"lname": "Jones ",
"salary": 75000.0,
"has401k": true,
"companyID": 1,
"healthPlanID": 1,
"name": "John Jones "
},
{
"id": 2,
"fname": "Sam",
"lname": "Ford",
"salary": 80000.0,
"has401k": true,
"companyID": 1,
"healthPlanID": 1,
"name": "Sam Ford"
},
{
"id": 1,
"fname": "Steve",
"lname": "Green",
"salary": 45000.0,
"has401k": true,
"companyID": 1,
"healthPlanID": 1,
"name": "Steve Green"
}
]
http://localhost:2019/data/employee/2
{
"id": 2,
"fname": "Sam",
"lname": "Ford",
"salary": 80000.0,
"has401k": true,
"companyID": 1,
"healthPlanID": 1,
"name": "Sam Ford"
}
http://localhost:2019/data/employees/s
[
{
"id": 2,
"fname": "Sam",
"lname": "Ford",
"salary": 80000.0,
"has401k": true,
"companyID": 1,
"healthPlanID": 1,
"name": "Sam Ford"
},
{
"id": 1,
"fname": "Steve",
"lname": "Green",
"salary": 45000.0,
"has401k": true,
"companyID": 1,
"healthPlanID": 1,
"name": "Steve Green"
}
]
http://localhost:2019/data/sortedemployees/s
[
{
"id": 1,
"fname": "Steve",
"lname": "Green",
"salary": 45000.0,
"has401k": true,
"companyID": 1,
"healthPlanID": 1,
"name": "Steve Green"
},
{
"id": 2,
"fname": "Sam",
"lname": "Ford",
"salary": 80000.0,
"has401k": true,
"companyID": 1,
"healthPlanID": 1,
"name": "Sam Ford"
}
]
http://localhost:2019/calc/salary/1/0.05
{
"id": 1,
"fname": "Steve",
"lname": "Green",
"salary": 47250.0,
"has401k": true,
"companyID": 1,
"healthPlanID": 1,
"name": "Steve Green"
}