Crudportal
Crudportal
entity;
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class CrudexApplication{
public static void main(String[] args) {
SpringApplication.run(CrudexApplication.class, args);
}
}
//SpringBootApplication
package com.example.demo.service;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import com.example.demo.entity.Employee;
package com.example.demo.controller;
import java.util.List;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.example.demo.entity.Employee;
import com.example.demo.service.EmpService;
@RestController
public class EmpController{
@GetMapping("/employees")
public List<Employee> getAllEmployees(){
return EmpService.getAllEmployees();
}
@GetMapping("/employee/{employeeId}")
public Employee getEmployeeDetails(@PathVariable int employeeId)
{
return EmpService.getEmployeeDetails(employeeId);
}
@PostMapping("/addEmployee")
public Employee addEmployee(@RequestBody Employee employee)
{
return EmpService.addEmployee(employee);
}
@PutMapping("/updateEmployee/{employeeId}")
public Employee updateEmployee(@PathVariable int employeeId, @RequestBody
Employee employee)
{
return EmpService.updateEmployee(employeeId, employee);
}
@DeleteMapping("/deleteEmployee/{employeeId}")
public Employee dEmploye(@PathVariable int employeeId)
{
return EmpService.dEmployee(employeeId);
}
}
//EmployeeController.java