This is a test assignment which is Java-based RESTful application to manage users through endpoints.
The project is developed using the following technologies and tools:
- Java(17)
- Spring Boot
- Spring Data JPA
- MySQL DB
- Swagger (for API documentation)
- Jakarta Validation
- JUnit
- Maven (for project management and checkstyle)
-
Register User:
- Endpoint:
POST /api/users - Description: Registers a new user by creating, validating, and saving user details to the database. (cannot register if under 18)
- Request Body: UserRegisterRequestDto
- Response: UserResponseDto
- HTTP Status Code: 201 Created
- Endpoint:
-
Update User Email by ID:
- Endpoint:
PATCH /api/users/{id} - Description: Updates the email of a user identified by their ID.
- Request Body: UpdateUserRequestDto
- Response: UserResponseDto
- HTTP Status Code: 200 OK
- Endpoint:
-
Update User by ID:
- Endpoint:
PUT /api/users/{id} - Description: Updates all user data fields by the specified user ID.
- Request Body: UserRegisterRequestDto
- Response: UserResponseDto
- HTTP Status Code: 200 OK
- Endpoint:
-
Delete User by ID:
- Endpoint:
DELETE /api/users/{id} - Description: Deletes a user from the database by the specified ID.
- Response: No content
- HTTP Status Code: 204 No Content
- Endpoint:
-
Search User by Birth Date Range:
- Endpoint:
GET /api/users/search - Description: Searches for users within the specified range of birth dates.
- Query Parameters:
from: Start date of the birth date rangeto: End date of the birth date range
- Response: List of UserResponseDto
- HTTP Status Code: 200 OK
- Endpoint:
- Spring Web: Used for building RESTful web services.
- Spring Boot Starter Validation: For request validation using annotations.
- Project Lombok: For reducing boilerplate code with annotations like
@RequiredArgsConstructor.
- Java-17 or above
- MySQL server 8.0.36 or above
- Apache Maven 3.6.3 or above
- Git latest version
To set up and use the project:
- Clone the repository:
git clone https://github.com/luk14n/user-api.git - Build the project using Maven:
mvn -X clean package. - Run the application:
java -jar target/*.jar. or just hit play button if using Inteliji IDEA - Access the Swagger documentation at
http://localhost:8080/swagger-ui.htmlfor detailed API information.