Esse projeto é uma API básica criada utilizando Java and Java Spring.
This project is a Basic Api created using Java and Java Spring.
- Clone the repository:
git clone git@github.com:PedroH183/ApiSpring.git
- Install dependencies with Maven
- Start the application with Maven
- The API will be accessible at http://localhost:8080
The API provides the following endpoints:
Create Product
POST /product/add - Create a new product
BODY
{
"name" : "Lâmpada",
"price_in_cents" : 2020
}
Update Product
PUT /product/edit/<ID_PRODUCT> - Update a product
BODY
{
"name" : "Mesa",
"price_in_cents" : 2020
}
Get All Products
GET /product/All
BODY
[
{
"id": "a7d1b143-9abc-49ef-8ed5-d51c31c4f0a0",
"name": "Lâmpada",
"price_in_cents": 2020
}
...
]
Delete a Product
DELETE /product/delete/<ID_PRODUCT>
This project follows some JPA conventions to connect with the database. Configure your connection in src/main/resources/application.properties.
Spring Resources to Connect your database
spring.datasource.url=jdbc:postgresql://localhost:5432/products_db
spring.datasource.username=postgres
spring.datasource.password=1234
Tabel Product
CREATE TABLE product(
id TEXT PRIMARY KEY UNIQUE NOT NULL,
name TEXT NOT NULL,
price_in_cents INT NOT NULL
);