Giter Site home page Giter Site logo

varshitverma / employee-list-3_spring-boot Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 73 KB

In this project we can manage the Employees data in the database. By using Restful API and performing CRUD (Create, Read, Update, Delete) operations on the Employee data

Java 100.00%
crud-operations h2-database java-8 jpa-hibernate spring-boot

employee-list-3_spring-boot's Introduction

Given five files,

  • EmployeeController.java
  • EmployeeRepository.java
  • EmployeeJpaService.java
  • EmployeeJpaRepository.java
  • Employee.java

And also given a database file employees which contains the EMPLOYEELIST table.

EMPLOYEELIST Table

Columns Type
employeeId INTEGER
employeeName TEXT
email TEXT
department TEXT
Use only `employeelist` as the table name in both query writing and in the model class within your code.

Completion Instructions

  • Employee.java: Employee class should contain the following attributes.

    Attribute Type
    employeeId int
    employeeName String
    email String
    department String
  • EmployeeRepository.java: Create an interface containing the required methods.

  • EmployeeJpaService.java: Update the service class with logic for managing employee data.

  • EmployeeController.java: Create the controller class to handle HTTP requests.

  • EmployeeJpaRepository.java: Create an interface that extends the JpaRpository Interface.

Implement the following APIs.

API 1

Path: /employees

Method: GET

Description:

Returns a list of all employees in the employeeList.

Response

[
    {
        "employeeId": 1,
        "employeeName": "John Doe",
        "email": "[email protected]",
        "department": "Marketing"
    },
   ...
]

API 2

Path: /employees

Method: POST

Description:

Creates a new employee in the employeeList. The employeeId is auto-incremented.

Request

{
    "employeeName": "Henry Nicholas",
    "email": "[email protected]",
    "department": "IT"
}

Response

{
    "employeeId": 7,
    "employeeName": "Henry Nicholas",
    "email": "[email protected]",
    "department": "IT"
}

API 3

Path: /employees/{employeeId}

Method: GET

Description:

Returns an employee details based on the employeeId. If the given employeeId is not found in the employeeList, raise ResponseStatusException with HttpStatus.NOT_FOUND.

Success Response

{
    "employeeId": 2,
    "employeeName": "Jane Smith",
    "email": "[email protected]",
    "department": "Human Resources"
}

API 4

Path: /employees/{employeeId}

Method: PUT

Description:

Update the details of an employee in the employeeList based on the employeeId and return the updated employee details. If the given employeeId is not found in the employeeList, raise ResponseStatusException with HttpStatus.NOT_FOUND.

Request

{
    "employeeName": "Steve Smith",
    "email": "[email protected]"
}

Success Response

{
    "employeeId": 2,
    "employeeName": "Steve Smith",
    "email": "[email protected]",
    "department": "Human Resources"
}

API 5

Path: /employees/{employeeId}

Method: DELETE

Description:

Deletes an 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

Do not modify anything in the application.properties file

Do not add any SQL files

employee-list-3_spring-boot's People

Contributors

varshitverma avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.