Skip to content

OGlovatska/restaurant-voting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restaurant voting application

Build a voting system for deciding where to have lunch:

  • 2 types of users: admin and regular users
  • Admin can input a restaurant and it's lunch menu of the day (2-5 items usually, just a dish name and price)
  • Menu changes each day (admins do the updates)
  • Users can vote on which restaurant they want to have lunch at
  • Only one vote counted per user
  • If user votes again the same day:
    • If it is before 11:00 we assume that he changed his mind.
    • If it is after 11:00 then it is too late, vote can't be changed

Each restaurant provides a new menu each day.

Swagger API-docs

Swagger UI

Swagger requests examples

Authorization credentials:

User:

Admin:

User Controller

API endpoint Pre authorize HTTP method Response code Request body example
/user User/Admin GET 200
/user User/Admin PUT 204
{
"email": "[email protected]",
"firstName": "Updated-First",
"lastName": "Updated-Last",
"password": "password",
"roles":[
"USER"
]
}
/user User/Admin DELETE 204
/user/register User/Admin POST 201
{
"email": "[email protected]",
"firstName": "New-First",
"lastName": "New-Last",
"password": "password",
"roles":[
"USER"
]
}

Restaurant Controller

API endpoint Pre authorize HTTP method Response code Request parameter example Request body example
/restaurant/{id} User/Admin GET 200 id=1
/restaurant/{id} Admin PUT 204 id=1
{
"name": "Updated Mario Trattoria"
}
/restaurant/{id} Admin DELETE 204 id=1
/restaurant Admin POST 201
{
"name": "Updated Mario Trattoria"
}
/restaurants User/Admin GET 200
/restaurants/today-menu User/Admin GET 200

Dish Controller

API endpoint Pre authorize HTTP method Response code Request parameter example Request body example
/dish/{id} Admin GET 200 id=1
/dish/{id} Admin PUT 204 id=1
{
"date": "2022-04-26",
"name": "Updated SALAD CAPRESE",
"price": 12,
"restaurant": {
"id": 1
}
}
/dish/{id} Admin DELETE 204 id=1
/dish Admin POST 201
{
"date": "2022-04-26",
"name": "New Dish",
"price": 30,
"restaurant": {
"id": 1
}
}
/dishes User/Admin GET 200 restaurantId=1
/dishes/by-date User/Admin GET 200 restaurantId=1
date=2022-04-26

Vote Controller

API endpoint Pre authorize HTTP method Response code Request parameter example
/vote User GET 200 date=2022-04-26
/vote User POST 201 restaurantId=1