API
Employee APIs
POST /employees– Create new employee (with optional address and department)GET /employees/{id}– Get employee by IDPUT /employees/{id}– Update employee detailsDELETE /employees/{id}– Delete employeeGET /employees?name=John&department=HR&page=0&size=10&sortBy=hireDate– Get paginated, sorted list of employees with optional filters (name, department, salary range, etc.)GET /employees/by-department/{deptId}– Get employees by departmentGET /employees/{id}/projects– Get all projects assigned to an employeeGET /employees/{id}/salaries– Get all salaries for an employeeGET /employees/search– Advanced search using specifications (name, date range, department, etc.)
DTO
EmployeeRequestDTO
EmployeeRequestDTOThis is used for creating or updating an employee.
public class EmployeeRequestDTO {
private String name;
private String email;
private String phone;
private LocalDate hireDate;
private Long departmentId;
private AddressDTO address; // embedded sub-object
}EmployeeResponseDTO
EmployeeResponseDTOThis is used for returning employee data to the client, including resolved department name, address details, and project names (if needed).
AddressDTO
AddressDTOUsed for both request and response to nest address within employee DTOs.
Controller
Repository
Specification Class
Mapper Interface
We can use MapStruct or manual mapping. Example using MapStruct:
Service Interface
Service Implementation
Department APIs
POST /departments– Create a new departmentGET /departments– List all departmentsGET /departments/{id}– Get department detailsPUT /departments/{id}– Update departmentDELETE /departments/{id}– Delete department
Controller
Service Interface
Service Implementation
Repository
DTO
DepartmentRequestDTO
DepartmentRequestDTODepartmentResponseDTO
DepartmentResponseDTOError Handling
Mapper Interface
Address APIs
POST /addresses– Add addressPUT /addresses/{id}– Update addressGET /addresses/{id}– Get address details
Controller
Service Interface
Service Implementation
Mapper Interface
MapStruct will auto-generate the implementation AddressMapperImpl.
Repository
DTO
AddressRequestDTO.java
AddressRequestDTO.javaAddressResponseDTO.java
AddressResponseDTO.javaProject APIs
POST /projects– Create new projectGET /projects?client=Google&budgetMin=100000– List all projects with filterGET /projects/{id}– Get project by IDPUT /projects/{id}– Update project detailsDELETE /projects/{id}– Delete project
Controller
Service Interface
Service Implementation
Repository
Mapper Interface
DTO
ProjectRequestDTO.java
ProjectRequestDTO.javaProjectResponseDTO.java
ProjectResponseDTO.javaSpecifications
Relationship APIs
POST /employees/{empId}/assign-project/{projId}– Assign a project to an employeeDELETE /employees/{empId}/remove-project/{projId}– Remove project assignment
Controller
Service Interface
Service Implementation
Salary APIs
POST /salaries– Add new salary record for employeeGET /salaries/employee/{empId}– Get all salaries for an employeeGET /salaries?month=2024-02&status=PAID&employeeId=4– Get salaries with pagination, filters (month/year/status/employeeId)PUT /salaries/{id}– Update salaryDELETE /salaries/{id}– Delete salary
Controller
Service Interface
Service Implementation
Repository
MapStruct Mapper Interface
DTO
Specification for Filtering
Payment History APIs
POST /payments– Add new payment history entryGET /payments/salary/{salaryId}– Get all payments for a salaryGET /payments– Paginated list with filters (date range, payment mode, etc.)
Controller
Service Interface
Service Implementation
Repository
MapStruct Mapper Interface
DTO
PaymentHistoryRequestDTO.java
PaymentHistoryRequestDTO.javaPaymentHistoryResponseDTO.java
PaymentHistoryResponseDTO.javaSpecifications
Dashboard & Reports
GET /dashboard/summary– Show employee counts, department-wise summary, salary spend etc.GET /reports/salary-summary?year=2024– Salary paid per employee/monthGET /reports/department-overview– Number of employees, active projects, total salary expense per department
1. GET /dashboard/summary
Controller
Service Interface
Service Implementation
DTO
Custom Query in Repository
2. GET /reports/salary-summary?year=2024
Controller
Service Interface
Service Implementation
DTO
Repository
3. GET /reports/department-overview
Controller
Service Interface
Service Implementation
DTO
Repository
Last updated