This project contains the api for thefoodu
You will need:
- Maven as your build tool
- Your favorite IDE
- JDK 1.8+
- PostgreSQL
You will need:
- Spring Data JPA
- PostgreSQL Connector
- Spring WEB
- JUnit
- JUnit Vintage Engine
- Spring Boot Test Starter
- Spring Boot Maven Plugin
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.
- Create a PostgreSQL database using the thefoodu.sql script provided in the root folder.
- 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
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
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
Get all pizzas
- URL
localhost:8080/pizzas
, METHOD = GET
Save a pizza
- 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