Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Azatick94/topjava-graduation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

76 Commits

Repository files navigation

topjava-graduation

Codacy Badge

TOPJAVA-GRADUATION PROJECT


project requirements

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 user

  • 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.

As a result, provide a link to github repository. It should contain the code, README.md with API documentation and couple curl commands to test it.


P.S.: Make sure everything works with latest version that is on github :)

P.P.S.: Assume that your API will be used by a frontend developer to build frontend on top of that.


* RESULTS


* SWAGGER documentation


* SECURITY CONFIGS

ADMIN:

admin@mail.ru : admin

USER:

user@mail.ru : user


* DATABASE MODEL STRUCTURE

alt text


* Postman Project Url


* LIST of CURL Commands

RESTAURANT CONTROLLER

- Get All Restaurants (user+admin):

curl --user user@mail.ru:user -L -X GET 'http://localhost:8080/rest/restaurants'

- Get Restaurant With ID = 100009 (user+admin):

curl --user user@mail.ru:user -L -X GET 'http://localhost:8080/rest/restaurants/100009'

- Save New Restaurant with Name="New_Restaurant" (admin):

curl --user admin@mail.ru:admin -L -X POST 'http://localhost:8080/rest/restaurants' -H 'Content-Type: application/json' --data-raw '{"restaurantName": "New_Restaurant"}'

- Update Restaurant With ID = 100009: (admin)

curl --user admin@mail.ru:admin -L -X PUT 'http://localhost:8080/rest/restaurants/100009' -H 'Content-Type: application/json' --data-raw '{"restaurantName": "Russian Pub New Name"}'

- Delete Restaurant With ID = 100010: (admin)

curl --user admin@mail.ru:admin -L -X DELETE 'http://localhost:8080/rest/restaurants/100010'

USER CONTROLLER

- Get All Users (admin):

curl --user admin@mail.ru:admin -L -X GET 'http://localhost:8080/rest/users'

- Find User By Name="Azat" (admin):

curl --user admin@mail.ru:admin -L -X GET 'http://localhost:8080/rest/users/by/name?name=Azat'

- Get User By Id=100000 (admin):

curl --user admin@mail.ru:admin -L -X GET 'http://localhost:8080/rest/users/by/id?id=100000'

LUNCH CONTROLLER

- Get All Lunches (admin+user):

curl --user user@mail.ru:user -L -X GET 'http://localhost:8080/rest/lunches'

- Get Lunch By Id = 100014 (admin+user):

curl --user user@mail.ru:user -L -X GET 'http://localhost:8080/rest/lunches/100014'

- Get List of Lunches By RestaurantId = 100008 (admin+user):

curl --user user@mail.ru:user -L -X GET 'http://localhost:8080/rest/lunches/by_restaurant?id=100008'

- Get List of Lunches Between Dates = (admin+user):

curl --user user@mail.ru:user -L -X GET 'http://localhost:8080/rest/lunches/filter/between?startDate=2021年01月02日&endDate=2021年01月02日'

- Get List of Lunches By Date = 2021年01月02日 = (admin+user):

curl --user user@mail.ru:user -L -X GET 'http://localhost:8080/rest/lunches/filter/date?date=2021年01月02日'

- Save New Lunch (admin):

curl --user admin@mail.ru:admin -L -X POST 'http://localhost:8080/rest/lunches' -H 'Content-Type: application/json' --data-raw '{"dateRegistered": "2021-05-10", "lunchName": "New Lunch", "price": 777, "restaurantId": 100008}'

- Update Existing Lunch With Id = 100014 (admin):

curl --user admin@mail.ru:admin -L -X PUT 'http://localhost:8080/rest/lunches/100014' -H 'Content-Type: application/json' --data-raw '{"dateRegistered": "2021-01-01","lunchName": "New Description","price": 710,"restaurantId": 100008}'

- Delete Lunch With Id = 100015 (admin):

curl --user admin@mail.ru:admin -L -X DELETE 'http://localhost:8080/rest/lunches/100015'

VOTE CONTROLLER

- Get Authorized User Votes (user):

curl --user user@mail.ru:user -L -X GET 'http://localhost:8080/rest/votes/user_votes'

- Get Vote By Id = 100034 (admin):

curl --user admin@mail.ru:admin -L -X GET 'http://localhost:8080/rest/votes/by/id?id=100034'

- Get Votes By Date (admin):

curl --user admin@mail.ru:admin -L -X GET 'http://localhost:8080/rest/votes/by/date?date=2021年01月01日'

- Save/Update Vote (user):

curl --user user@mail.ru:user -L -X POST 'http://localhost:8080/rest/votes' -H 'Content-Type: application/json' --data-raw '{"restaurantId": 100009}'

About

topjava-graduation project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

Languages

AltStyle によって変換されたページ (->オリジナル) /