Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maarceloluiz/springboot-crud-apirest-client
https://github.com/maarceloluiz/springboot-crud-apirest-client
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/maarceloluiz/springboot-crud-apirest-client
- Owner: MaarceloLuiz
- Created: 2024-11-24T17:24:43.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-24T18:22:23.000Z (about 2 months ago)
- Last Synced: 2024-11-24T19:30:31.298Z (about 2 months ago)
- Language: Java
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Clients CRUD - Spring Boot
## Objective
Develop a RESTful API with full CRUD operations for managing clients.## Features
- Paginated client list
- Search clients by ID
- Add new clients
- Update existing clients
- Delete clients
- Exception handling for:
- Resource not found (404)
- Validation errors (422)## Domain Model
- **Client**: Contains fields for `id`, `name`, `CPF`, `income`, `birthDate`, and `children`.![image](https://github.com/user-attachments/assets/563a27c8-0a57-47cb-8a04-fa9be3938a1c)
## Tech && Frameworks
- **Spring Boot**: Framework for building the REST API.
- **JPA/Hibernate**: ORM for database management.
- **H2 Database**: In-memory database for testing.
- **Postman**: For testing the API endpoints.
- **Maven**: Build automation.## How to Run
### Prerequisites
- Java 8 or higher
- Maven### Steps
#### 1. Clone the repository:
```bash
git clone https://github.com/MaarceloLuiz/springboot-crud-apirest-client.git
cd springboot-crud-apirest-client
```
#### 2. Build the project using Maven and run the Application:
```bash
mvn clean install
mvn spring-boot:run
```
#### 3. Open Postman (or any API testing tool).
#### 4. Use the following base URL to access the API endpoints:
```bash
http://localhost:8080
```
#### 5. The available endpoints include:
- GET /clients - Retrieve a paginated list of clients.
- You can use query parameters such as page, size, and sort to control the pagination:
- **page**: Page number (starting from 0).
- **size**: Number of results per page.
- **sort**: Sorting field (e.g., name).
- For example: to retrieve the second page of clients with 10 results per page, sorted by name:
```bash
http://localhost:8080/clients?page=1&size=10&sort=name
```
- GET /clients/{id} - Retrieve client details by ID.
- POST /clients - Add a new client (requires a JSON body).
- PUT /clients/{id} - Update an existing client by ID.
- DELETE /clients/{id} - Delete a client by ID.#### For example, you can test the GET /clients endpoint in Postman by sending a request to:
```bash
http://localhost:8080/clients
```#### 6. To stop the application run the following command in the terminal:
```bash
mvn spring-boot:stop
```## Author
Marcelo Luiz Guimarães Pereira---