This project provides a simple Employee Management REST API built using Spring Boot and Java 8. The API allows you to perform CRUD (Create, Read, Update, Delete) operations on Employee data.
- Java 8
- Spring Boot
- PostgreSQL
- Maven
Ensure the following environment variables are set before running the application:
DB_HOST=your-database-host
DB_PORT=5432
DB_NAME=your-db-name
SPRING_DATASOURCE_USERNAME=your-db-username
SPRING_DATASOURCE_PASSWORD=your-db-password
spring.datasource.url=jdbc:${DB_PLATFORM}://${DB_HOST}:${DB_PORT}/${DB_NAME}
spring.datasource.username=${SPRING_DATASOURCE_USERNAME}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}
spring.jpa.show-sql=true
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
Request:
GET /api/v1/employees
Response:
[
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"emailId": "john.doe@example.com"
}
]
Request:
GET /api/v1/employees/{id}
Response:
{
"id": 1,
"firstName": "John",
"lastName": "Doe",
"emailId": "john.doe@example.com"
}
Request:
POST /api/v1/employees
Content-Type: application/json
Body:
{
"firstName": "Jane",
"lastName": "Smith",
"emailId": "jane.smith@example.com"
}
Response:
{
"id": 2,
"firstName": "Jane",
"lastName": "Smith",
"emailId": "jane.smith@example.com"
}
Request:
PUT /api/v1/employees/{id}
Content-Type: application/json
Body:
{
"firstName": "Jane",
"lastName": "Doe",
"emailId": "jane.doe@example.com"
}
Response:
{
"id": 2,
"firstName": "Jane",
"lastName": "Doe",
"emailId": "jane.doe@example.com"
}
Request:
DELETE /api/v1/employees/{id}
Response:
{
"deleted": true
}
For any issues, feel free to open an issue or contribute to the project!