Skip to content

apolik/graduation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voting Application

Application for deciding where to have lunch. The task was:

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.

Usage

  • Clone this repository to your machine
  • Open up terminal and navigate to the root directory
  • Make sure you've maven and java 17 installed
  • Run 'mvn spring-boot:run'

🐬 Docker

  • docker-compose up

Swagger UI documentation

http://localhost:8080/swagger-ui.html

Credentials

User:  [email protected] / kanye
Admin: [email protected] / admin
Test user: [email protected] / testuser

Curl commands

1. Get all Restaurants

curl -s http://localhost:8080/api/restaurants --user [email protected]:kanye

2. Get Restaurant with id 3

curl -s http://localhost:8080/api/restaurants/3 --user [email protected]:kanye

3. Get Restaurant not found

curl -s http://localhost:8080/api/restaurants/1017 --user [email protected]:kanye

4. Create Restaurant

curl -s -X POST -d '{"name": "Anderson"}' -H 'Content-Type:application/json;charset=UTF-8' http://localhost:8080/api/admin/restaurants --user [email protected]:admin

5. Delete Restaurant with id 2

curl -s -X DELETE http://localhost:8080/api/admin/restaurants/2 --user [email protected]:admin

6. Get all Dishes

curl -s http://localhost:8080/api/dishes --user [email protected]:kanye

7. Get all Dishes restaurant 3

curl -s http://localhost:8080/api/dishes?restaurantId=3 --user [email protected]:kanye

8. Create Dish for Restaurant with id 3

curl -s -X POST -d '{"name": "new dish","price": 1017.0,"restaurantId": 3,"entryDate": "2022-05-21"}' -H 'Content-Type:application/json;charset=UTF-8' http://localhost:8080/api/admin/dishes --user [email protected]:admin

9. Delete Dish with id 6

curl -s -X DELETE http://localhost:8080/api/admin/dishes/6 --user [email protected]:admin

10. Get all Votes

curl -s http://localhost:8080/api/profile/voting --user [email protected]:kanye

11. Vote for Restaurant with id 4

curl -s -X POST -d '{"restaurantId": 3}' -H 'Content-Type:application/json;charset=UTF-8' http://localhost:8080/api/profile/voting --user [email protected]:testuser

Application stack

Spring Boot, Spring MVC, Spring Security, Spring Data JPA, Hibernate ORM, JUnit 5, AssertJ, Apache Tomcat, Hibernate Validator, SLF4J, Json Jackson, Springdoc OpenAPI UI, Mockito, Java 17, Caffeine cache

About

Выпускной проект стажировки

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •