Skip to content

harshit-sharma2005/Employee-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Employee Management System

A Spring Boot REST API for employee management with full CRUD operations, validation, and testing.

🚀 Features

  • Complete CRUD operations for employee management
  • Advanced search by ID, email, department, salary range, and name
  • Data validation with custom error messages
  • RESTful API with standard HTTP methods
  • H2 in-memory database for quick setup
  • Comprehensive testing (40 tests total)
  • Pre-loaded with 8 sample employees

🛠️ Tech Stack

  • Java 17
  • Spring Boot 3.5.0
  • Spring Data JPA
  • H2 Database
  • Maven
  • JUnit 5

� Quick Start

  1. Clone & Run

    git clone https://github.com/harshit-sharma2005/Employee-Management-System.git
    cd Employee-Management-System
    .\mvnw spring-boot:run
  2. Access Application

📡 API Endpoints

Method Endpoint Description
GET /api/employees Get all employees
GET /api/employees/{id} Get employee by ID
GET /api/employees/email/{email} Get employee by email
GET /api/employees/department/{dept} Get employees by department
POST /api/employees Create new employee
PUT /api/employees/{id} Update employee
DELETE /api/employees/{id} Delete employee

📄 Example Usage

Get All Employees:

curl http://localhost:8081/api/employees

Create Employee:

curl -X POST http://localhost:8081/api/employees \
  -H "Content-Type: application/json" \
  -d '{
    "firstName": "John",
    "lastName": "Doe",
    "email": "[email protected]",
    "department": "IT",
    "salary": 75000.0
  }'

🧪 Testing

# Run all tests
.\mvnw test

# Test specific class
.\mvnw test -Dtest=EmployeeControllerTest

🗃️ Sample Data

Pre-loaded with 8 employees across IT, HR, Finance, and Marketing departments.

🔧 Configuration

Database: H2 In-Memory

  • URL: jdbc:h2:mem:testdb
  • Username: sa
  • Password: password

Server Port: 8081

🛡️ Validation

Employee fields include validation for:

  • Required fields (firstName, lastName, email, department, salary)
  • Email format validation
  • Custom error messages

🐛 Troubleshooting

Port conflict:

netstat -ano | findstr :8081
taskkill /PID <process-id> /F

Java version: Requires Java 17+

📝 License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages