Design and implement a REST API using Hibernate/Spring/SpringMVC (or Spring-Boot) without frontend.
The task is:
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 asume that he changed his mind.
- If it is after 11:00 then it is too late, vote can't be changed
- Each restaurant provides new menu each day.
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/admin/users'
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/admin/users/100000'
- Example:
curl --location --request POST 'http://localhost:8080/graduation/rest/admin/users/'
--data-raw '{
"name": "Ivan",
"email": "[email protected]",
"password": "12345",
"roles": [
"ROLE_USER"
],
"enabled": true
}'
- Example:
curl --location --request PUT 'http://localhost:8080/graduation/rest/admin/users/'
--data-raw '{ "id": 100000, "name": "User", "email": "[email protected]", "password": "12345", "roles": [ "ROLE_USER" ], "enabled": true }'
- Example:
curl --location --request DELETE 'http://localhost:8080/graduation/rest/admin/users/100000'
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/admin/users/[email protected]' \
- Example:
curl --location --request POST 'http://localhost:8080/graduation/rest/profile/register'
--data-raw '{ "name": "Some user", "email": "[email protected]", "password": "12345" }'
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/profile'
- Example:
curl --location --request PUT 'http://localhost:8080/graduation/rest/profile/'
--data-raw '{ "name": "Good user", "email": "[email protected]", "password": "12345" }'
- Example:
curl --location --request DELETE 'http://localhost:8080/graduation/rest/profile' \
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/admin/restaurants' \
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/admin/restaurants/100002' \
- Example:
curl --location --request POST 'http://localhost:8080/graduation/rest/admin/restaurants'
--data-raw '{ "name": "McDonalds" }'
- Example:
curl --location --request PUT 'http://localhost:8080/graduation/rest/admin/restaurants'
--data-raw '{ "id": 100021, "name": "McDonalds - restaurant" }'
- Example:
curl --location --request DELETE 'http://localhost:8080/graduation/rest/admin/restaurants/100015'
--header 'Authorization: Basic YWRtaW5AZ21haWwuY29tOmFkbWlu'
- Example:
curl --location --request POST 'http://localhost:8080/graduation/rest/admin/menus/'
--data-raw '{ "restaurant_id": 100003, "dishes": { "paltus": 10000, "wine":1245 } }'
- Example
curl --location --request POST 'http://localhost:8080/graduation/rest/admin/menus/future?date=2020-05-27'
--data-raw '{ "restaurant_id": 100003, "dishes": { "potato": 1000, "fish": 2000, "tea": 500 } }'
- Example
curl --location --request PUT 'http://localhost:8080/graduation/rest/admin/menus'
--data-raw '{ "dishes": { "dish4": 500, "dish5": 700, "new dish": 800 }, "id": 100007 }'
Method GET: Returns one menu with given id
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/admin/menus/100007' \
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/menus/today'
- Example: curl --location --request GET 'http://localhost:8080/graduation/rest/menus/bydate?date=2015-05-30' \
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/admin/voteresult?date=2015-05-30'
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/admin/todayvoteresult' \
- Example:
curl --location --request POST 'http://localhost:8080/graduation/rest/votes?menuId=100007' \
Method PUT: Change authorized user's vote for menu which id was given as parameter 'menuId' (possible only till 11:00 AM)
- Example:
curl --location --request PUT 'http://localhost:8080/graduation/rest/votes?menuId=100008' \
- Example:
curl --location --request GET 'http://localhost:8080/graduation/rest/votedmenu?date=2020-05-25' \