Food court microservice
πIn this challenge, you are tasked with designing the backend of a system that centralizes the services and orders of a restaurant chain with multiple branches across the city. This microservice is responsible for implementing the business logic related to the food court, ensuring seamless operations and delightful dining experiences. π―πThis microservice communicates with the user, messaging, and traceability microservice. For this, it is necessary to execute or launch said microservices for proper operation.
Get ready to power up the food court and create a robust backend solution that optimizes processes, manages orders, and enhances the overall efficiency of the restaurant chain. Let's embark on this exciting journey! πͺπ
To get a local copy up and running follow these steps.
- βπ§17 JDK 17 https://jdk.java.net/java-se-ri/17
- π¦π§Gradle https://gradle.org/install/
- π¬π§MySQL https://dev.mysql.com/downloads/installer/
- IntelliJ Community https://www.jetbrains.com/idea/download/
- Postman https://www.postman.com/downloads/
- Clone the repository π₯π§
- Change directory
cd power-up-arquetipo-v3
- Create a new database in MySQL called powerup1
- Update the database connection settings βοΈπ§
# src/main/resources/application-dev.yml spring: datasource: url: jdbc:mysql://localhost/powerup1 username: root password: <your-password>
- After the tables are created execute src/main/resources/data.sql content to populate the database
- Open Swagger UI and search the /auth/login endpoint and login with userDni: 123, π΅οΈββοΈπ§password: 1234
- Right-click the class FoodCourtApplication and choose Run
- Open http://localhost:8091/swagger-ui/index.html in your web browser
- Right-click the test folder and choose Run tests with coverage
You can test the API using a tool like Postman or any REST client of your choice.
- Endpoint: POST /auth/login
- Request body /json:
{
"mail": "john_doe@gmail.com",
"password": "password123"
}
Example of a successful response:
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huX2RvZSIsImlhdCI6MTYzMzI1NDkzMCwiZXhwIjoxNjMzMTQxMzMwfQ.2_5te1vQjDG-yTeBEOsmBAPdQHzCmCtojmYHltWkWbI",
"tokenType": "Bearer"
}
- Endpoint: POST /api/v1/restaurant
- Request body /json:
{
"name": "frisby",
"adress": "cr 45-85",
"phone": "84674128",
"urlLogotype": "string",
"nit": "70491543",
"idOwner": "1235896"
}
Example of a successful response:
{
"message": "Restaurant created"
}
Endpoint: GET /api/v1/restaurant
Example of a successful response:
[
{
"id": 1,
"name": "Frisby",
"adress": "cr 45-85",
"phone": "84674128",
"urlLogotype": "string",
"nit": "70491543",
"idOwner": "1235896"
},
{
"id": 2,
"name": "Presto",
"adress": "cr 25-85",
"phone": "7754128",
"urlLogotype": "http_presto",
"nit": "5896543",
"idOwner": "236598745"
},
{
"id": 3,
"name": "Dominos",
"adress": "cr 75-85",
"phone": "4584128",
"urlLogotype": "http//Logo/dominos.com",
"nit": "4589624",
"idOwner": "58933585"
}
]
- Endpoint: GET /api/v1/restaurant/page/{page}/size/{size} Example of URL: /api/v1/restaurant/page/1/size/2
Example of a successful response:
[
{
"id": 1,
"name": "Frisby",
"adress": "cr 45-85",
"phone": "84674128",
"urlLogotype": "string",
"nit": "70491543",
"idOwner": "1235896"
},
{
"id": 2,
"name": "Presto",
"adress": "cr 25-85",
"phone": "7754128",
"urlLogotype": "http_presto",
"nit": "5896543",
"idOwner": "236598745"
}
]
- Endpoint: POST /api/v1/order
- Request body /json:
{
"restaurantId": 1,
"customerId": 1,
"items": [
{
"itemId": 1,
"quantity": 2
},
{
"itemId": 2,
"quantity": 1
}
]
}
Example of a successful response:
{
"orderId": 1,
"message": "Orden creada"
}
- Endpoint: PUT /api/v1/order/takeOrderAndUpdateStatus/{idOrder}/status/{state}
- Example of URL: /api/v1/order/takeOrderAndUpdateStatus/1/status/READY
Example of a successful response:
{
"orderId": 1,
"message": "Order updated"
}
- Endpoint: PUT /api/v1/order/notifyOrderReady/{idOrder}
- Example de URL: /api/v1/order/notifyOrderReady/1
Example of a successful response:
{
"orderId": 1,
"message": "Orden notificada como lista"
}
- Endpoint: PUT /api/v1/order/deliverOrder/{idOrder}/pin/{pin}
- Example of URL: /api/v1/order/deliverOrder/1/pin/1234
Example of a successful response:
{
"orderId": 1,
"message": "Orden entregada"
}
- Endpoint: PUT /api/v1/order/cancelOrder/{idOrder}
- Example de URL: /api/v1/order/cancelOrder/1
Example of a successful response:
{
"orderId": 1,
"message": "Orden cancelada"
}
- Endpoint: GET /api/v1/order/logs/{idOrder}
- Example of URL: /api/v1/order/logs/1
Example of a successful response:
[
{
"duration_Pending_to_Preparing": "34 min",
"duration_Preparing_to_Ready": "15 min",
},
{
"duration_Pending_to_Preparing": "34 min",
"duration_Preparing_to_Ready": "15 min",
"duration_Readyto_Delivered": "10 MIN"
}
]
- Endpoint: GET /api/v1/order/getOrdersByState/page/{page}/size/{size}/state/{state}
- Example of URL: /api/v1/order/getOrdersByState/page/1/size/10/state/in_progress
Example of a successful response:
[
{
"orderId": 1,
"restaurantId": 1,
"customerId": 1,
"state": "PENDING",
"items": [
{
"itemId": 1,
"quantity": 2
},
{
"itemId": 2,
"quantity": 1
}
]
},
{
"orderId": 2,
"restaurantId": 1,
"customerId": 2,
"state": "in_progress",
"items": [
{
"itemId": 3,
"quantity": 3
}
]
}
]
- Endpoint: POST /api/v1/dish
- Request body /json:
{
"restaurantId": 1,
"name": "Pizza Margherita",
"description": "Deliciosa pizza margherita con salsa de tomate, mozzarella y albahaca.",
"price": 12.99
}
Example of a successful response:
{
"dishId": 1,
"message": "Dish added successfully"
}
- Endpoint: PUT /api/v1/dish/{id}/activate/{enableDisable} Example of URL: /api/v1/dish/1/activate/true
Example of a successful response:
{
"dishId": 1,
"message": "Plato habilitado"
}
- Endpoint: PATCH /api/v1/dish/
- Request body /json:
{
"dishId": 1,
"name": "Pizza Margherita",
"description": "Deliciosa pizza margherita con salsa de tomate, mozzarella y albahaca.",
"price": 14.99
}
Example of a successful response:
{
"dishId": 1,
"message": "Plato actualizado exitosamente"
}
- Endpoint: GET /api/v1/dish/{idRestaurant}/page/{page}/size/{size}
- Example of URL: /api/v1/dish/1/page/0/size/2
Example of a successful response:
[
{
"dishId": 1,
"restaurantId": 1,
"name": "Pizza Margherita",
"description": "Deliciosa pizza margherita con salsa de tomate, mozzarella y albahaca.",
"price": 12.99,
"isActive": true
},
{
"dishId": 2,
"restaurantId": 1,
"name": "Hamburguesa ClΓ‘sica",
"description": "Hamburguesa de carne con lechuga, tomate, cebolla y queso.",
"price": 10.99,
"isActive": true
}
]