Application user-management-app is a solution of HSBC user management task.
These instructions will get you a copy of the project up and running on your local machine.
Maven is required to build application. Java Runtime Environment (JRE) 8 is required to run application. The application has been tested for compatibility with Maven version 3.6.1 and Java 8 Update 201.
To build an application, execute the Maven command:
mvn package spring-boot:repackage
To skip compiling and running tests use command:
mvn package spring-boot:repackage -Dmaven.test.skip=true
The application will be packed into user-management-app-1.0.0.jar and placed in target directory. To run application use command:
java -jar target/user-management-app-1.0.0.jar
By default, the application starts at:
http://localhost:8080
- Spring Boot Version: 2.1.5-RELEASE
- Maven - Dependency Management
- RSQL Parser - RSQL parser used for search requests. Version: 2.0.0
- Mapstruct - Generating mappers. Version: 1.3.0
- Swagger - API documentation. Version: 2.9.2
Generates API documentation and provides tools for sending requests. Swagger UI is available at:
http://localhost:8080/swagger-ui.html
- H2 Database - In-memory project database. Version: 2.9.2
Database storing user entities. Database console available at:
http://localhost:8080/h2-console
Default database properties:
URL: jdbc:h2:mem:usermanagementDB
User Name: user
Password:
Application provides REST endpoints for managing users data. Application supports Polish and English language versions. English is the default language. The language can be set in the header:
Accept-Language: pl-PL
Create new user.
URL : /users/
Method : POST
All fields must be filled. Request can not be empty.
- name - varchar [1 to 64 chars]
- surname - varchar [1 to 64 chars]
- grade - integer [not null]
- surname - integer [not null]
{
"user": {
"grade": 0,
"name": "string",
"salary": 0,
"surname": "string"
}
}
{
"user": {
"id": 13,
"name": "string",
"surname": "string",
"grade": 0,
"salary": 0
},
"_links": {
"self": {
"href": "http://localhost:8080/users/13"
},
"delete": {
"href": "http://localhost:8080/users/13"
},
"update": {
"href": "http://localhost:8080/users/13"
},
"users": {
"href": "http://localhost:8080/users"
}
}
}
{
"status": 400,
"error": "Bad Request",
"timestamp": "00:00:02:250 01/06/2019",
"messages": [
"Request validation error occurred while processing request.",
"Null User grade. User has to get specified not null grade."
]
}
Retrieves user by ID from database.
URL : /users/{ID}
Method : GET
{
"user": {
"id": 13,
"name": "string",
"surname": "string",
"grade": 0,
"salary": 0
},
"_links": {
"self": {
"href": "http://localhost:8080/users/13"
},
"delete": {
"href": "http://localhost:8080/users/13"
},
"update": {
"href": "http://localhost:8080/users/13"
},
"users": {
"href": "http://localhost:8080/users"
}
}
}
{
"status": 404,
"error": "Not Found",
"timestamp": "00:00:02:250 01/06/2019",
"messages": [
"User with id=34 does not exist."
]
}
Updates specified fields of the user of given ID in database.
URL : /users/{ID}
Method : PUT
Only specified user fields will be updated. Any number of fields can be specified for update.
- name - varchar [0 to 64 chars]
- surname - varchar [0 to 64 chars]
- grade - integer
- surname - integer
{
"user": {
"grade": 0,
"name": "string",
"salary": 0,
"surname": "string"
}
}
{
"user": {
"id": 13,
"name": "string",
"surname": "string",
"grade": 0,
"salary": 0
},
"_links": {
"self": {
"href": "http://localhost:8080/users/13"
},
"delete": {
"href": "http://localhost:8080/users/13"
},
"update": {
"href": "http://localhost:8080/users/13"
},
"users": {
"href": "http://localhost:8080/users"
}
}
}
{
"status": 404,
"error": "Not Found",
"timestamp": "00:00:02:250 01/06/2019",
"messages": [
"User with id=34 does not exist."
]
}
Deletes user with given ID from database.
URL : /users/{ID}
Method : DELETE
{
"status": 404,
"error": "Not Found",
"timestamp": "00:00:02:250 01/06/2019",
"messages": [
"User with id=34 does not exist."
]
}
Retrieves pages of users matching given criteria from database.
URL : /users/{?search}{?page,size,sort}
Method : GET
Searching criteria are specified with a standard of RSQL: https://github.com/jirutka/rsql-parser
http://localhost:8080/api/users?search=name==jo*,salary=gt=25&page=1&size=2&sort=name,asc&sort=surname,desc
{
"_embedded":{
"userResourceList":[
{
"user":{
"id":11,
"name":"Donald",
"surname":"Foreman",
"grade":2,
"salary":12000
},
"_links":{
"self":{
"href":"http://localhost:8080/users/11"
},
"delete":{
"href":"http://localhost:8080/users/11"
},
"update":{
"href":"http://localhost:8080/users/11"
},
"users":{
"href":"http://localhost:8080/users"
}
}
},
...
"_links":{
"first":{
"href":"http://localhost:8080/users?search=name==jo*,salary=gt=25&page=0&size=2&sort=name,asc&sort=surname,desc"
},
"prev":{
"href":"http://localhost:8080/users?search=name==jo*,salary=gt=25&page=0&size=2&sort=name,asc&sort=surname,desc"
},
"self":{
"href":"http://localhost:8080/users?search=name==jo*,salary=gt=25&page=1&size=2&sort=name,asc&sort=surname,desc"
},
"next":{
"href":"http://localhost:8080/users?search=name==jo*,salary=gt=25&page=2&size=2&sort=name,asc&sort=surname,desc"
},
"last":{
"href":"http://localhost:8080/users?search=name==jo*,salary=gt=25&page=5&size=2&sort=name,asc&sort=surname,desc"
},
"users":{
"href":"http://localhost:8080/users"
}
},
"page":{
"size":2,
"totalElements":12,
"totalPages":6,
"number":1
}
}
{
"status": 500,
"error": "Internal Server Error",
"timestamp": "12:11:24:676 01/06/2019",
"messages": [
"An unexpected internal server error occurred while processing request."
]
}
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Michał Gogolewski