REST API using Maven/Hibernate/Spring/SpringMVC/Security?REST(Jackson),
Java 8 Stream and Time API Storage in databases HSQLDB, Swagger
- 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
mvn clean verify org.codehaus.cargo:cargo-maven2-plugin:runThe application has Swagger UI.
After starting APP you need to go about url : http://localhost:8080/voting-system/
Login/Password for testing:
ADMIN: [email protected] / admin
USER: [email protected] / password
curl samples (application deployed at application context voting-system). For windows use Git Bash
get All Restaurants (RequestParam - withMenu=false/true , default withMenu=true)
curl -s http://localhost:8080/voting-system/profile/restaurants/ --user [email protected]:passwordRESULT
[ { "id": 100003, "name": "Colonies" }, { "id": 100002, "name": "Debasus" }, { "id": 100004, "name": "The Lounge Cafe" } ]
get Restaurant (RequestParam - withMenu=false/true , default withMenu=true)
curl -s http://localhost:8080/voting-system/profile/restaurants/100002 --user [email protected]:passwordRESULT
{ "id": 100002, "menu": [ { "date": "2020-12-22", "id": 100005, "name": "Bear", "price": 120 }, { "date": "2020-12-22", "id": 100006, "name": "Garlic bread", "price": 670 }, { "date": "2020-12-22", "id": 100007, "name": "BBQ ribs", "price": 340 } ], "name": "Debasus" }
get Vote (vote to the current date)
curl -s http://localhost:8080/voting-system/profile/votes --user [email protected]:passwordcreate Vote
curl -s -X POST http://localhost:8080/voting-system/profile/restaurants/100003/votes --user [email protected]:passwordupdate Vote (you can only change your voice until 11:00AM)
curl -s -X PUT http://localhost:8080/voting-system/profile/restaurants/100004/votes/100019 --user [email protected]:password
get All Restaurants (RequestParam - withMenu=false/true , default withMenu=true)
curl -s http://localhost:8080/voting-system/profile/restaurants --user [email protected]:admincreate Restaurant
curl -s -X POST -d '{"name":"NewRestaurant"}' -H 'Content-Type:application/json;charset=UTF-8' http://localhost:8080/voting-system/admin/restaurants --user [email protected]:admincreate new Dish
curl -s -X POST -d '{"date":"2020-12-21","name":"BigMac ","price":777}' -H 'Content-Type:application/json;charset=UTF-8' http://localhost:8080/voting-system/admin/restaurants/100003/dishes --user [email protected]:adminget All Dishes For Restaurant (order by date)
curl -s http://localhost:8080/voting-system/admin/restaurants/100003/dishes --user [email protected]:admindelete Dish
curl -s -i -X DELETE http://localhost:8080/voting-system/admin/restaurants/100003/dishes/100010 --user [email protected]:admin