aatifansari / Employee-REST_API

Springboot project to implement RESTful webservices to perform CRUD operation on MySQL database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Employee-REST_API

Springboot project to implement RESTful webservices to perform CRUD operations on employee resource using MySQL database. Hibernate used for object relation mapping and maven for build automation. Backend separated into resource, service and repository(DAO) layers.

Application Architecture

Application_architecture

Project Directory

image

Database Schema

image

Employee Object fields

  • id
  • firstName
  • lastName
  • email

APIs Description

1. Add Employee

Request Method & Endpoint - POST https://{host_name}/api/employees

  • addEmployee() - save new employee data into the table. Input data is passed as json in the request body

Postman Request and Response

AddEmployeePostman

Database

POST_Add_Employee_DB

2. Get All Employees

Request Method & Endpoint - GET https://{host_name}/api/employees

  • findAll() - fetch entire employee table data and return a json file

Postman Request and Response

GetAllEmployeePostman

Database

GetAllEmployeeDB

3. Get Employee By Id

Request Method & Endpoint - GET https://{host_name}/api/employees/{employeeId}

  • findById() - fetch specific employee data from table using employeeId path variable. Exception Handling - If employeeId does not exists in table runtime exception displaying "Employee id not found" is thrown back.

Postman Request and Response

GetEmployeeByIdPostman

4. Update Employee

Request Method & Endpoint - PUT https://{host_name}/api/employees

  • updateEmployee - update existing employee data in the table using id attribute. Input data is passed as json in the request body

Postman Request and Response

UpdateEmployeePostman

Database

UpdateEmployeeDB

5. Delete Employee By Id

Request Method & Endpoint - DELETE https://{host_name}/api/employees/{employeeId}

  • deleteEmployee - delete specific employee data from table using employeeId path variable. Exception Handling - If employeeId does not exists in table runtime exception displaying "Employee id not found" is thrown back.

Postman Request and Response

DeleteEmployeePostman

Database

DeleteEmployeeDB

Technology Stack

  • Java 17
  • Framework - Springboot
  • ORM - Hibernate
  • RDBMS - MySQL
  • Server - Embedded Tomcat Server
  • Build Tool - Maven

About

Springboot project to implement RESTful webservices to perform CRUD operation on MySQL database


Languages

Language:Java 100.0%