Skip to content

agniramadani/java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Rest Api

This project contains the api for thefoodu

Table of Contents

  1. Tools
  2. Dependencies
  3. Getting Started
  4. Database
  5. REST Endpoints

Tools

You will need:

Table of Contents

  1. Tools
  2. Dependencies
  3. Getting Started
  4. Database
  5. REST Endpoints

Dependencies

You will need:

Getting Started

First, clone the project:

$ https://github.com/Lenarty/java.git

Second, open the project using your favorite IDE and install all the listed dependencies above and you should be able to run the application.

If everything works, you should see an Index Page here.

Database

  1. Create a PostgreSQL database using the thefoodu.sql script provided in the root folder.
  2. Add credentials to /src/main/resources/application.properties

The default ones are:


spring.datasource.driverClassName=org.postgresql.Driver

spring.datasource.url=jdbc:postgresql://localhost:5432/thefoodu

spring.datasource.username=postgres

spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

spring.jpa.show-sql=true

REST Endpoints

Company Endpoints

Get all companies

  • URL localhost:8080/companies, METHOD = GET

Save a company

  • URL localhost:8080/company, METHOD = POST, expects JSON body (only company_name is required)

Find company by id

  • URL localhost:8080/company/{id}, METHOD = GET

Update Company by id

  • URL localhost:8080/company/{id}, METHOD = PUT, expects JSON body (id must be the same as previous and company_name can be modified)

Delete a company

  • URL localhost:8080/company/{id}, METHOD = DELETE

Food Endpoints

Get all foods

  • URL localhost:8080/foods, METHOD = GET

Save food

  • URL localhost:8080/food, METHOD = POST, expects JSON body (only food_name is required)

Find food by id

  • URL localhost:8080/food/{id}, METHOD = GET

Update Food by id

  • URL localhost:8080/food/{id}, METHOD = PUT, expects JSON body (id must be the same as previous and food_name can be modified)

Delete a company

  • URL localhost:8080/food/{id}, METHOD = DELETE

Pizza Endpoints

This process is the same for other foods as well

Get all pizzas

  • URL localhost:8080/pizzas, METHOD = GET

Save a pizza

Before saving pizza first you have to insert food and than to save the food id on this table

  • URL localhost:8080/pizza, METHOD = POST, expects JSON body (pizza_name, food_name is required)

Find pizza by id

  • URL localhost:8080/pizza/{id}, METHOD = GET

Check if pizza exists by id

  • URL localhost:8080/pizza/{id}, METHOD = GET

Delete a pizza

  • URL localhost:8080/pizza/{id}, METHOD = DELETE

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%