Skip to content

Snoke19/order_management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to run this project with docker

Docker runs MySQL database and spring rest API with predefined data of goods!

Rest API:

  • port - 8080

MySql Database:

  • port: 3306

Clone project

git clone https://github.com/Snoke19/order_management.git

Go to the project folder and run docker-compose

cd ./order_management

docker compose up

Run tests with Maven and all tests working with test-containers with predefined database

cd ./order_management

./mvnw clear test

Endpoints

Manager

Add a new good:

curl -X POST --location "http://localhost:8080/api/v1/good" \
    -H "Content-Type: application/json" \
    -d "{
          \"description\": \"IPhone 11\",
          \"name\": \"IPhone 11 - best phone!\",
          \"price\": 40000,
          \"quantity\": 5
        }"

Get all available goods:

curl -X GET --location "http://localhost:8080/api/v1/goods" \
    -H "Content-Type: application/json"
[
  {
    "name": "iPhone 12",
    "description": "Flagship smartphone from Apple",
    "price": 1000,
    "quantity": 50,
    "id": 1
  }
]

Client

Create a new order and you can add many good for buying:

curl -X POST --location "http://localhost:8080/api/v1/order" \
    -H "Content-Type: application/json" \
    -d "{
          \"infoGoodOrders\": [{
            \"idGood\": 7,
            \"quantityBuy\": 2
          }]
        }"

Get all orders:

curl -X GET --location "http://localhost:8080/api/v1/orders" \
    -H "Content-Type: application/json"
[
  {
    "orderId": 1,
    "created": "2023-11-17T00:01:58",
    "status": "PAID",
    "orderGoodDetails": [
      {
        "goodId": 7,
        "name": "Samsung Galaxy Tab S7",
        "price": 600,
        "quantityBuy": 2
      }
    ]
  }
]

Pay for order

curl -X POST --location "http://localhost:8080/api/v1/order/pay" \
    -H "Content-Type: application/json" \
    -d "{
          \"orderId\": 1
        }"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published