This project is a Spring Boot application that includes various functionalities such as employee management, validation, and global exception handling. The project uses Maven for dependency management.
- Java
- Spring Boot
- Maven
This class represents the Data Transfer Object for an employee and includes various validation annotations to ensure data integrity.
This class handles exceptions globally across the application. It includes handlers for:
ResourceNotFoundException
Exception
MethodArgumentNotValidException
This class implements ResponseBodyAdvice
to wrap all responses in a consistent format using the ApiResponse
class.
@NotBlank
@Size
@Email
@NotNull
@Max
@Min
@PositiveOrZero
@Digits
@DecimalMin
@DecimalMax
@PastOrPresent
@AssertTrue
@Positive
@FutureOrPresent
@CreditCardNumber
@Range
@AssertFalse
@PasswordValidation
@EmployeeRoleValidation
@PrimeNumberValidation
-
Create Employee
- URL:
/api/employees
- Method:
POST
- Request Body:
EmployeeDTO
- Response:
ApiResponse<EmployeeDTO>
- Description: Creates a new employee.
- URL:
-
Get Employee by ID
- URL:
/api/employees/{id}
- Method:
GET
- Response:
ApiResponse<EmployeeDTO>
- Description: Retrieves an employee by their ID.
- URL:
-
Update Employee
- URL:
/api/employees/{id}
- Method:
PUT
- Request Body:
EmployeeDTO
- Response:
ApiResponse<EmployeeDTO>
- Description: Updates an existing employee.
- URL:
-
Delete Employee
- URL:
/api/employees/{id}
- Method:
DELETE
- Response:
ApiResponse<Void>
- Description: Deletes an employee by their ID.
- URL:
-
Resource Not Found
- Status:
404
- Response:
ApiResponse<ApiError>
- Description: Returned when a requested resource is not found.
- Status:
-
Internal Server Error
- Status:
500
- Response:
ApiResponse<ApiError>
- Description: Returned when an internal server error occurs.
- Status:
-
Method Argument Not Valid
- Status:
400
- Response:
ApiResponse<ApiError>
- Description: Returned when input validation fails.
- Status:
- Clone the repository.
- Navigate to the project directory.
- Run
mvn spring-boot:run
.
Tech-savvy learner/programmer pushing boundaries of online tech. Passionate about new tools, seeking challenges to advance skills.