Skip to content

Lozitsky/voting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Codacy Badge

#private voting system

Maven Spring Boot Security JPA(Hibernate) REST(Jackson) Tests(JUnit4)



Demo project "Voting for restaurants"

How does it work?

The administrator creates a menu every day. In addition, when he will create the first dish, the entity of the voting will be automatically created. Voting possible only if dishes present today. If restaurant don't containes any dish for todays date that voting impossible. Admin also can update or delete menu. If admin will update some old dish that the entity of the voting for this restaurant will be automatically created. Every restaurant have entity of vote for avery day when it contains menu.
Users can vote every day for the different restaurants which contains menu. If user wants vote again for another restaurant that he can do it until to 11:00 am. After he can do it in another day. User can vote from 00:01 to 24:00


Admin
  • can registration( For example: get all restaurants admin@gmail.com : password )
  • can add restaurants(name and description)
  • can add restaurants dishes(name and price)
  • can watch the voting history(by restaurant Id, by date)
  • can watch list of restaurants
  • can watch list of dishes
  • can change field enable(true|false) for users
  • can’t vote
  • can’t delete admins or users

User
  • can registration( For example: get result or list menu with restaurants user2@yandex.ru : password )
  • can vote( For example: vote for restaurant with id 10006)
  • can watch voting after the vote (if he has not voted, he will redirect to the voting list)
  • can change his voice by 11 o’clock
  • can vote between 00:00 and 23:59
  • can’t add or remove restaurants and dishes and other entities

Voting
  • from 00:00 to 23:59
  • the user can vote for the menu that was created or updated by the Administrator today
  • the system have a voting history by date

Menu
  • the system have a menu(dishes) history by date

Dish
  • consist of the name and price

Curl commands

For testing on localhost. If you want testing on cloud service Heroku you need change "http://localhost:8080" to "https://voting-rest.herokuapp.com"

Notes. After 30 minutes of inactivity, Heroku needs some time (~ 2 minutes) to start the system.
  • Get list all the restaurants(only for Admin):
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/restaurants
  • Get restaurant by Id(only for Admin):
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/restaurant/10004
  • Get restaurants with dishes(only for Admin):
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/restaurants/dishes
  • Get restaurant with dishes by Id(only for Admin):
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/restaurants/dishes/10006
  • Get restaurant with dishes by date(only for Admin):
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/restaurants/dishes/date/2017-11-11
  • Get all the restaurants with voices(only for Admin):
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/restaurants/votes
  • Get restaurant with voices by Id(only for Admin):
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/restaurants/votes/10005
  • Get restaurant with voices by date(only for Admin):
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/restaurants/votes/date/2018-01-11
  • Get munu(dishes) with the restaurants for voting(only for User):
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic dXNlckB1a3IubmV0OnBhc3N3b3Jk' -i http://localhost:8080/rest/user/dishes/forVoting
  • Create dish by restaurant id(only for Admin):
    curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/dish/10008 --data '{"name":"Some Dish3 блюдо","price":350}'
  • Update dish by id(only for Admin):
    curl -X PUT -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/dish/10022 --data '{"name":"New Dish блюдо","price":453}'
  • Delete dish by id(only for Admin)
    curl -X DELETE -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/dish/10021
  • Create restaurant(only for Admin):
    curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/restaurant --data '{"name":"Ресторан Golden Star","description":"text текст"}'
  • Update restaurant by Id(only for Admin):
    curl -X PUT -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/restaurant/10007 --data '{"name":"Ресторан NEW Star","description":"new текст"}'
  • Delete Restaurant(only Admin):
    curl -X DELETE -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/restaurant/10008
  • Get user by id(only for Admin)
    curl -X GET -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/user/10002
  • Get all users(only for Admin)
    curl -X GET -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/users
  • Set the user field with the name enabled to true by id(only for Admin)
    curl -X PUT -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/user/on/10003
  • Set the user field with the name enabled to false by id(only for Admin)
    curl -X PUT -H 'Authorization: Basic YWRtaW5AZ21haWwuY29tOnBhc3N3b3Jk' -i http://localhost:8080/rest/admin/user/off/10003
  • Get results voting or redirect when you don't vote(only for User)
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic dXNlckB1a3IubmV0OnBhc3N3b3Jk' -i http://localhost:8080/rest/user/votes
  • Vote for a restaurant by restaurant Id(only for User and only one time if more than 11:00)
    curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Basic dXNlckB1a3IubmV0OnBhc3N3b3Jk' -i http://localhost:8080/rest/user/voteFor/10006

For testing on Firefox can try RESTClient


10.2018

© Created by Kirilo Lozitsky

Email for questions