Skip to content

Elgedr/Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API documentation

How to deploy the application?

  • Open project in IntelliJ IDEA or another IDE
  • In file application properties write your mysql login and password.(usually by default it is root)

Firs variant via MySQL Workbench

You can download MySQL here https://www.mysql.com/downloads/

  • Go to the MySQL Workbench
    1. Launch MySQL Workbench and click the + button to open the Setup New Connection wizard

Screenshot 2022-03-04 200751

    1. Enter the name for the connection and username, then click Test Connection. Enter the password in the dialog asking for the password

Screenshot 2022-03-04 201032

    1. In the MySQL Workbench window that opens, click the Create a new schema in the connected server button on the main toolbar. Then enter the schema name (adcash), and click Apply

Screenshot 2022-03-04 201322

    1. In the Apply SQL Script to Database window that opens, click Apply. Then click Finish

Screenshot 2022-03-04 201519

  • Run project in Inteliji clicking on Run Screenshot 2022-03-04 202010

Second variant via MySQL Command Line Client

  • Run the client
  • Enter your password
  • Execute the create database command. Database name is adcash Screenshot 2022-03-04 202415

Entity relationship diagram

Screenshot 2022-03-04 001946

You can test api using Postman. You can download it here https://www.postman.com/downloads/postman-agent/

NB! For a more beautiful output of the JSON, you can install this extension https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh?hl=ru

In Postman go to Workspaces -> My Workspace -> press + . Screenshot 2022-03-04 202810

Create a category

Firstly, you should create a category.

unnamed (1)

  • For creating a new category, you should write the category’s name. Press “Body” then choose “raw” and choose ‘“JSON”.

unnamed

  • Write category’s name like this { “categoryName”: “wanted category name” }

  • Press “Send”

If you try to create the category with the existing name you will get the error “Category already exists!” unnamed (2)

Create a product

  • For this, use http://localhost:8080/products and choose a POST method
  • Repeat all steps from “create a category”, write parameters for a new product like that: { “productName”: “wanted product name”, “productDescription”: “wanted product description” }
  • As every product has a category, you should give a category id the product belongs to. Choose “Params”, write under the key categoryId and tick this key. As a value write needed category Id

unnamed (3)

Get all categories

unnamed (4)

Get all products

Update category’s name

  • Use http://localhost:8080/categories/{id} and choose a PUT method
  • Instead of {id} in the URL, write the id of the category to be updated
  • In params under the “Key” write the “name”(field to be changed) and under the “Value” wanted new name value

unnamed (7)

  • Press “Send”

You will get a product with a changed name

Update product’s name

  • Use http://localhost:8080/products/{id} and choose a PUT method
  • Instead of {id} in the URL, write the id of the product to be updated
  • In params under the “Key” write the “name”(field to be changed) and under the “Value” wanted new name value
  • Press “Send”

You will get a product with a changed name

Delete category

  • Use http://localhost:8080/categories/{id} and choose a DELETE method
  • Instead of {id} in the URL, write the id of the category to be deleted
  • Press “Send” You will get deleted category’s Id

unnamed (8)

Delete product

  • Use http://localhost:8080/products/{id} and choose a DELETE method
  • Instead of {id} in the URL, write the id of the product to be deleted
  • Press “Send” You will get deleted category’s Id

Get products by category

Also, you can get a product or category by id using GET method and http://localhost:8080/products/{id} or http://localhost:8080/categories/{id}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published