This microservice provides a simple RESTful API for managing a list of invoices. It allows users to perform CRUD (Create, Read, Update, Delete) operations on invoices and implements error handling and unit tests for the service layer.
After starting the application locally, here you can reach out to the swagger: http://localhost:8080/swagger-ui/index.html
- Java 8 or higher
- Docker
- PostgreSQL
- Spring Boot
- PostgreSQL Database
- Docker
Clone the Repository:
git clone https://github.com/CodeLikeAlexito/invoice-taulia.gitStart the PostgreSQL database using Docker Compose:
docker-compose upNavigate to the root directory of the project and run the Spring Boot application:
./gradlew bootRun
Or open the application in IntelliJ IDEA or different IDE and run it from there.
There is base spring security implemented. There is need for Basic Authorization only for POST, PATCH and DELETE endpoints. All GET endpoints are accessible from everyone.
- Username: alex
- Password: 123
POST /invoices
{
"invoiceNumber": "25",
"buyerId": "9ad76928-a991-4f9d-b208-de70dc3dcc5b",
"supplierId": "b460755d-2863-44b7-9948-e4f5fe6c2415",
"dueDate": "2023-05-10",
"items": [
{
"description": "fsafa",
"quantity": 1,
"price": 125.2
}
]
}GET /invoices/{id}
GET /invoices
JSON Patch: https://www.baeldung.com/spring-rest-json-patch
PATCH /invoices/{id}
[
{ "op": "replace", "path": "/invoiceNumber", "value": "24515125" }
]DELETE /invoices/{id}
This are just some of the main endpoints, you can check all of them in the swagger.
The microservice handles errors such as invalid input, non-existing invoices, etc., and returns appropriate error responses with status codes.