Skip to content

DmitryPodkutin/voting_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Codacy Badge

Voting system for deciding where to have lunch.

REST API using Maven/Hibernate/Spring/SpringMVC/Security?REST(Jackson),
Java 8 Stream and Time API Storage in databases HSQLDB, Swagger

Description

  • 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

Starting Project

mvn clean verify org.codehaus.cargo:cargo-maven2-plugin:run

REST UI Documentation

The 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

Commands for Using application

curl samples (application deployed at application context voting-system). For windows use Git Bash

- user -

get All Restaurants (RequestParam - withMenu=false/true , default withMenu=true)

curl -s http://localhost:8080/voting-system/profile/restaurants/ --user [email protected]:password
RESULT

[ { "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]:password
RESULT

{ "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]:password

create Vote

curl -s -X POST http://localhost:8080/voting-system/profile/restaurants/100003/votes  --user [email protected]:password

update 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

- admin -

get All Restaurants (RequestParam - withMenu=false/true , default withMenu=true)

curl -s http://localhost:8080/voting-system/profile/restaurants  --user [email protected]:admin

create 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]:admin

create 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]:admin

get All Dishes For Restaurant (order by date)

curl -s http://localhost:8080/voting-system/admin/restaurants/100003/dishes --user [email protected]:admin

delete Dish

curl -s -i -X DELETE http://localhost:8080/voting-system/admin/restaurants/100003/dishes/100010  --user [email protected]:admin

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages