/ApiSpring

A minimal API to introduce learning about Spring with data persistence using a relational database.

Primary LanguageJava

Basic Api Crud

Java Spring Licence

PT-BR

Esse projeto é uma API básica criada utilizando Java and Java Spring.

EN-US

This project is a Basic Api created using Java and Java Spring.

Table of Contents

Installation

  1. Clone the repository:
git clone git@github.com:PedroH183/ApiSpring.git
  1. Install dependencies with Maven

Usage

  1. Start the application with Maven
  2. The API will be accessible at http://localhost:8080

API Endpoints

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> 

Database

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
);