Git Product home page Git Product logo

rest-api-showroom's Introduction

REST API - Showroom

The Showroom REST API creates brands and adds products to those brands.

Isaiah Jenkins

Technologies

  • Java (Server-side language)
  • Hibernate (ORM)
  • MySQL (Server)
  • MySQL Workbench (visual database design tool for MySQL database)
  • Jersey (JAX-RS)
  • Tomcat (Web server)
  • Postman (REST Client)
  • Maven (Dependency Injection)
  • Eclispe (IDE, Jave EE version 2020-12)

Download Eclispe IDE, MySQL tools, and Postman

  1. Eclispe (IDE, Java EE version 2020-12)
  2. MySQL Community Server
  3. MySQL Workbench
  4. Postman

Set up schema and tables on MySQL Workbench

Note: Make sure to start your MySQL server on your computer.

Schema - showroom

Screen Shot 2021-03-10 at 1 57 38 PM

Tables - brands, products

Screen Shot 2021-03-10 at 2 01 21 PM

Screen Shot 2021-03-10 at 2 02 17 PM

In the products table, set up a foreign key for brand id referenced to the brands table in showroom schema. Each product is tagged to a brand with the brand's id.

Screen Shot 2021-03-10 at 2 10 10 PM

How to run the project

  1. Open Eclipse.
  2. Right-click on "restapi" project folder.
  3. Click Run As -> Run on Server.
  4. Make sure the web server is the latest Tomcat for v9.x.x.
  5. Hit Finish.

Use Postman to test application

Important: Make sure the Content-type header is set to application/json for the requests except for DELETE operation.

Create a brand

Ex:

POST http://localhost:8080/restapp/showroom/brands 

In BODY, send raw JSON object like below

{
    "brandName": "my brand"
}

Get all brands

Ex: 

GET http://localhost:8080/restapp/showroom/brands

No body

Get brand by brand id

Ex: 

GET http://localhost:8080/restapp/showroom/brands/4

No body

Get products by brand id

Ex: 

GET http://localhost:8080/restapp/showroom/brands/4/products

No body

Get products by brand id and category

Ex: 

GET http://localhost:8080/restapp/showroom/brands/4/products?category=clothing

No body

Update brand name by brand id

Ex: 

PUT http://localhost:8080/restapp/showroom/brands/16

In BODY, send raw JSON object like below

{
    "brandId": 16,
    "brandName": "brand18"
}

Delete brand by id

Ex: 

DELETE http://localhost:8080/restapp/showroom/brands/16

No body

rest-api-showroom's People

Contributors

jenkins1128 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.