-
Notifications
You must be signed in to change notification settings - Fork 7
/
EmployeeController.java
55 lines (43 loc) · 2.11 KB
/
EmployeeController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.dev2pro.springdatajpa.controller;
import com.dev2pro.springdatajpa.entity.Employee;
import com.dev2pro.springdatajpa.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class EmployeeController {
@Autowired
EmployeeService employeeService;
@PostMapping("/saveEmployees")
public List<Employee> saveEmployees(@RequestBody List<Employee> employeeList){
return employeeService.saveEmployeeData(employeeList);
}
@GetMapping("/getEmployee")
public List<Employee> getEmployees(){
return employeeService.getEmployees();
}
@GetMapping("/getEmployeeById/{empId}")
public Employee getEmployees(@PathVariable Long empId){
return employeeService.getEmployeeById(empId);
}
@DeleteMapping("/deleteEmployeeByDesignation/{designation}")
public List<Employee> deleteEmployeeByDesignation(@PathVariable String designation){
return employeeService.deleteEmployeeByDesignation(designation);
}
@GetMapping("/getEmployeeByDesignation/{designation}")
public Employee getEmployeesByDesignation(@PathVariable String designation){
return employeeService.getEmployeeByDesignation(designation);
}
@RequestMapping(value = "/pagingAndShortingEmployees/{pageNumber}/{pageSize}", method = RequestMethod.GET)
public Page<Employee> employeePagination(@PathVariable Integer pageNumber, @PathVariable Integer pageSize){
return employeeService.getEmployeePagination(pageNumber,pageSize, null);
}
@RequestMapping(value = "/pagingAndShortingEmployees/{pageNumber}/{pageSize}/{sortProperty}",
method = RequestMethod.GET)
public Page<Employee> employeePagination(@PathVariable Integer pageNumber,
@PathVariable Integer pageSize,
@PathVariable String sortProperty) {
return employeeService.getEmployeePagination(pageNumber, pageSize, sortProperty);
}
}